Savon HTTP :: ERROR但没有更多信息?

时间:2012-11-05 13:04:01

标签: soap ruby-on-rails-3.1 savon

我正在尝试使用此代码配置我的rails应用程序与soap webservice交谈:

client = Savon::Client.new do
  wsdl.document = "http://services.carsolize.com/BookingServices/dynamicdataservice.svc?wsdl"
end

response = client.request "ServiceRequest", "xmlns" => "http://tempuri.org/" do |soap, wsdl|
  client.http.headers["SOAPAction"] = '"http://tempuri.org/IDynamicDataService/ServiceRequest"'
  soap.body = {
    "rqst" => {
      "Credentials" => {
        "UserName" => 'user',
        "Password"  => 'pass'
      },
      "RequestType" => "Login", 
      "TypeOfService" => "Unknown",
    },
  }
end

但我得到的是HomeController #index中的Savon :: HTTP :: Error(并且没有更多信息)以响应开头。

1 个答案:

答案 0 :(得分:0)

我试过这样做

client = Savon.client 'http://services.carsolize.com/BookingServices/dynamicdataservice.svc?wsdl'

username = '*********'
password = '*********'

response = client.request :wsdl, :login do
  http.headers["SOAPAction"] = '"http://tempuri.org/IDynamicDataService/ServiceRequest"'
  soap.xml = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><ServiceRequest xmlns='http://tempuri.org/'><rqst xmlns:i='http://www.w3.org/2001/XMLSchema-instance'><Credentials xmlns=''>
  <Password>#{password}</Password><UserName>#{username}</UserName></Credentials><RequestType xmlns=''>Login</RequestType><TypeOfService xmlns=''>Unknown</TypeOfService></rqst></ServiceRequest></s:Body></s:Envelope>"
end

它工作正常