![](/img/trans.png)
[英]How to get request and response header in Savon SOAP request with rails
[英]Rails 3.1 Savon soap request giving Timeout::Error: Timeout::Error ut using curl i get response
我在使用rails 3.1中的savon構建soap客戶端時遇到了麻煩。 但是當我嘗試從curl命令行發出請求時,我能夠成功獲得響應。 我從命令行的curl請求看起來像這樣
curl -d @Downloads/test.xml -H "content-type: text/xml;charset=UTF-8" -H "SOAPAction: http://services.bamnetworks.com/registration/identityPoint/create" "https://qaservices.bamnetworks.com/ws/services/IdentityPointService" -v
從中我得到了這樣的完美回應。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header /><soapenv:Body><identityPoint_create_response xmlns="http://services.bamnetworks.com/registration/types/1.6"><status><code>-2000</code><message> [Duplicate credential constraint violated] [com.bamnetworks.registration.types.exception.DuplicateCredentialException]</message><exceptionClass>com.bamnetworks.registration.types.exception.DuplicateCredentialException</exceptionClass>
但是當我每次嘗試向Savon客戶提出請求時
HTTPI executes HTTP POST using the net_http adapter
Timeout::Error: Timeout::Error
我的Savon請求看起來像這樣
client = Savon::Client.new do |wsdl, http|
http.auth.ssl.verify_mode = :none
wsdl.document = "https://qaservices.bamnetworks.com/ws/services/IdentityPointService?wsdl"
end
begin
response = client.request :ns, :identityPoint_create_request do |soap, wsdl, http|
http.headers['SOAPAction'] = 'http://services.bamnetworks.com/registration/identityPoint/create'
http.headers = { "Content-Length" => "0", "Connection" => "Keep-Alive" }
soap.namespaces["xmlns:ns0"]="http://services.bamnetworks.com/application/types/1.0"
soap.header = {
"ns0:appCredentials" => {
"ns0:name"=>"XXXXXXX",
"ns0:password"=>"XXXXXXXXX"
}
}
soap.body ={
:identification => {
:email => {
:address => "mlb_user@mlb.com"
},
:password => { :address => { :id => 44 } }
},
:profileProperty => {
:name => "birthDay",
:value => "17"
},
:profileProperty => {
:name => "birthMonth",
:value => "8"
},
:profileProperty => {
:name => "birthYear",
:value => "1986"
},
:attributes! => { :identification => { :type => "email-password" } }
}
end
我不知道我在哪里弄錯了。 如果有人幫我解決這個問題。 謝謝!
這可能是肥皂服務器問題嘗試評論行:
http.headers = { "Content-Length" => "0", "Connection" => "Keep-Alive" }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.