0

我正在使用 savon 来使用 API。以下是我的代码中的行。

 wSDL = "some_wsdl"
 client = Savon::Client.new(wSDL)     
 response = client.soap_action do |soap|
 soap.body = "<sample>string_value</sample>" , "<sample1>string_value</sample1>"
 end

我收到一个错误(标题),下面是应用程序跟踪。顺便说一句,我的 wsdl 是https://some_wsdl格式,如果这很重要的话。

/var/lib/gems/1.8/gems/savon-0.7.9/lib/savon/response.rb:141:in `handle_soap_fault'
/var/lib/gems/1.8/gems/savon-0.7.9/lib/savon/response.rb:81:in `initialize'
/var/lib/gems/1.8/gems/savon-0.7.9/lib/savon/client.rb:95:in `new'
/var/lib/gems/1.8/gems/savon-0.7.9/lib/savon/client.rb:95:in `method_missing'
app/controllers/deposit_controller.rb:33:in `deposit'
4

1 回答 1

0

不知道为什么会出现错误,但是通过将肥皂主体构建为字符串来使生活变得困难。Savon 从哈希构建 SOAP 请求,因此以下内容将更轻松地完成您想要的操作

wSDL = "some_wsdl"
client = Savon::Client.new(wSDL)     

# Add more details here including nested hashes    
request_hash = {
  "sample" => string_value,
  "sample1" => string_value
}

response = client.soap_action do |soap|
  soap.body = request_hash
end
于 2010-06-24T13:29:53.773 回答