tags:

views:

22

answers:

1

I am using savon to consume an API. Below are lines from my code.

 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

I am getting an error (title) and below is the application trace. Btw, my wsdl is in https://some_wsdl format, if that matters.

/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'
A: 

Not sure why you are getting the error but you are making life difficult by building the soap body as a string. Savon build SOAP requests from Hashes so the following will do what you want somewhat more easily

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
Steve Weet