2013-06-03 34 views
1

我已經使用savon編寫了與SOAP API的集成。我遇到了似乎只有在某些操作系統的問題。我之所以這樣說是因爲相同的代碼在CentOS6和MacOSX上工作,但拒絕使用Ubuntu12.04。我正在使用的代碼是:使用HTTP身份驗證的Savon HTTPS請求

@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上完成這項工作?

這絕對不是一個用戶名和密碼錯誤,因爲一個確切的副本在另一個操作系統上工作。

任何有關這個問題的幫助,將不勝感激。謝謝!

回答

1

問題出在HTTPI正在使用的HTTP客戶端上。出於某種原因,HTTPCLIENT不能滿足我需要的功能。所以我只是gem uninstall httpclient

之後,HTTPI自動拾取net_http,它像一個冠軍!

-3

HTTP error (401)表示您嘗試授權失敗。通常這是用戶名/密碼的問題。進入HTML返回它說:

HTTP Status 401 - No user credentials found 

我認爲你需要確保你的用戶名和密碼是正確的。

+0

我已經雙重檢查了用戶名和密碼。另外,我將它從遠程存儲庫中拖放到兩個不同的操作系統上,它可以在一個操作系統上運行,另一個則會引發此錯誤。 –