6

I'm using savon 2.2 for making SOAP calls.

Initialize:

  client = Savon.client(
  wsdl: SOAP_WSDL,
  endpoint: SOAP_URL)

I can make a SOAP call like this and it works fine:

resp =  client.call(:login, message: { username: SOAP_USER, password: SOAP_PASSWORD })

Now I need to make another call which requires setting some parameters in the SOAP header. From the documentation on savorb.com I found I should use the request method:

 response = client.request :get_user_info do
    soap.header = { :session_id => sid }
 end 

But I'm getting an error saying that the request method does not exist:

undefined method `request' for #<Savon::Client:0x007f1560f80490>

Do I have a different version of savon or what?? I tried using "call" instead of "request" but then I'm getting:

ArgumentError - wrong number of arguments (1 for 2):
gem) savon-2.2.0/lib/savon/options.rb:35:in `method_missing'
(gem) savon-2.2.0/lib/savon/block_interface.rb:20:in `method_missing'
app/models/tool.rb:23:in `block in doUpload'
Ya.
  • 1,671
  • 4
  • 27
  • 53

3 Answers3

9

You're on Savon 2.2.0. You should use

response = client.call(:get_user_info, :soap_header => { :session_id => sid })

'request' is a method from version 1.x and not supported anymore.

Steffen Roller
  • 3,464
  • 25
  • 43
1

What if you create a new Savon client with the session id?

client = Savon.client(
  wsdl: SOAP_WSDL,
  endpoint: SOAP_URL,
  soap_header: {
    "Header" => { "session_id" => sid }
  }
)

client.call(:get_user_info, message: data)
zwippie
  • 15,050
  • 3
  • 39
  • 54
1

Or like this, for both a header and body:

@response = @client.call(operation, { :message => message, :soap_header => header })
Hendrik
  • 41
  • 2