【问题标题】:Savon HTTPS Request with HTTP authentication带有 HTTP 身份验证的 Savon HTTPS 请求
【发布时间】:2013-06-03 23:37:36
【问题描述】:

我使用 savon 编写了与 SOAP API 的集成。我遇到了似乎只与某些操作系统有关的问题。我这么说的原因是因为相同的代码适用于 CentOS6 和 MacOSX,但它拒绝适用于 Ubuntu12.04。我使用的代码是:

@client = Savon.client do
  wsdl "mywsdl"
  basic_auth ["username", "password"]
end

@client.call(:set_session_parameters, message: {viewSettings: {rollingPeriod: "Today", shiftStart: "25200000", statisticsRange: "CurrentDay",timeZone: -21600000}})

我得到的错误是:

[2013-06-03T18:22:31.784007 #16304] DEBUG -- : HTTPI POST request to api.five9.com (httpclient)
I, [2013-06-03T18:22:42.413083 #16304]  INFO -- : SOAP response (status 401)
D, [2013-06-03T18:22:42.413378 #16304] DEBUG -- : <html><head><title>JBoss Web/2.1.3.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - No user credentials found</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>No user credentials found</u></p><p><b>description</b> <u>This request requires HTTP authentication (No user credentials found).</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/2.1.3.GA</h3></body></html>
Savon::HTTPError: HTTP error (401): <html><head><title>JBoss Web/2.1.3.GA - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - No user credentials found</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>No user credentials found</u></p><p><b>description</b> <u>This request requires HTTP authentication (No user credentials found).</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/2.1.3.GA</h3></body></html>
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/savon-2.2.0/lib/savon/response.rb:71:in `raise_soap_and_http_errors!'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/savon-2.2.0/lib/savon/response.rb:13:in `initialize'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/savon-2.2.0/lib/savon/operation.rb:53:in `new'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/savon-2.2.0/lib/savon/operation.rb:53:in `call'
    from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/savon-2.2.0/lib/savon/client.rb:36:in `call'

就像我在其他操作系统上所说的那样,代码可以正常工作。我需要安装什么东西才能在 Ubuntu12.04 上运行吗?

这绝对不是用户名和密码错误,因为确切的副本可以在另一个操作系统上运行。

任何有关此问题的帮助将不胜感激。谢谢!

【问题讨论】:

    标签: ruby soap soap-client savon httpi


    【解决方案1】:

    问题在于 HTTPI 使用的 HTTP 客户端。由于某种原因,HTTPCLIENT 不能满足我的需要。所以我只是gem uninstall httpclient

    之后,HTTPI 会自动获取 net_http,它的工作原理就像一个冠军!

    【讨论】:

    【解决方案2】:

    HTTP error (401) 表示您的授权尝试失败。通常这是用户名/密码的问题。深入到返回的 HTML 中,它说:

    HTTP Status 401 - No user credentials found
    

    我认为您需要确保您的用户名和密码正确。

    【讨论】:

    • 我已经仔细检查了用户名和密码。另外,我将它从远程存储库拉到两个不同的操作系统上,它可以在一个操作系统上运行,而在另一个操作系统上它会引发此错误。
    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 2015-09-21
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多