1

I'm consuming a simple SOAP web service to get a small piece of HTML to be included in a Rails site. Unfortunately, I'm not particularly familiar with SOAP.

I need to call the TopHtml() SOAP method on the endpoint below but I need to also pass an ID number like TopHtml(29).

I'm using the Savon gem and my code looks a little something like:

response = Savon::Client.new('http://www.xxxxxx.xxx/webservices/services.asmx?wsdl').top_html(29)

which works but returns the default response for when an ID number was not provided.

It seems that the ID number is not being passed. Does anyone know how to pass parameters to Savon SOAP requests?

Many thanks, Tristan

tristanm
  • 3,337
  • 2
  • 27
  • 40

2 Answers2

1

try

response = Savon::Client.new('http://www.xxxxxx.xxx/webservices/services.asmx').top_html { |soap| soap.body = { :id => 29} }
Jake
  • 12,713
  • 18
  • 66
  • 96
  • According to the Savon docs this should work. However, when looking at the request object the attributes set on soap.body aren't appearing. – tristanm Nov 11 '10 at 00:18
1

In the interests of time, I ended up preparing the request XML myself which is less than ideal (and almost defeats the purpose of using Savon) but it's the only way I could have the request prepared properly. The XML was provided by the developers of the service.

client = Savon::Client.new 'http://www.xxxxxx.xxx/webservices/services.asmx?wsdl'

response = client.top_html do |soap|
    soap.xml = ...long xml here...
end

Yuck but I'm not going to spend anymore time on it.

tristanm
  • 3,337
  • 2
  • 27
  • 40