(soap:Server)服务器无法处理请求。 --->字符串引用未设置为String的实例。参数名称:s

时间:2010-06-24 03:48:25

标签: ruby soap savon

我使用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'

1 个答案:

答案 0 :(得分:0)

不确定为什么会收到错误,但是通过将肥皂体构建为字符串会使生活变得困难。 Savon从Hashes构建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