SOAP4R newbie question

Just started playing with SOAP4R and its very cool.

I’m trying to access a service that requires users to logon before doing
stuff, my first effort was as follows:

require ‘soap/rpc/driver’

base = ‘http://foo.bar.com/services/

logon_service = SOAP::RPC::Driver.new(base + ‘LogonService?wsdl’, nil)
logon_service.add_method(‘login’, ‘username’, ‘password’)
logon_service.login(‘foo’, ‘bar’)

do_stuff_service = SOAP::RPC::Driver.new(base + ‘DoStuffService?wsdl’, nil)
do_stuff_service.add_method(‘getThing’)
do_stuff_service.getThing()

This logs in to the first service okay, but calls to DoStuffService fail
with ‘not logged in’. I assume this is because the login/session details
are maintained by cookies and so I need to invoke both services from the
same driver.

Something like:

single_service = SOAP::RPC::Driver.new(base, nil)
single_service.add_method(‘login’, ‘username’, ‘password’)
Single_service.add_method(‘getThing’)

I just cant figure out how to tell each method to use which service (i.e…
namespace) …

Should I be using add_method_with_soapaction? Or is it restricted to one
service/namespace per driver?

···

The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express
written permission of the sender. If you are not the intended recipient, please
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.

Hi,

From: “Allton, Paul” Paul.Allton@DrKW.com
Sent: Thursday, March 11, 2004 7:31 PM

I’m trying to access a service that requires users to logon before doing
stuff, my first effort was as follows:

require ‘soap/rpc/driver’

base = ‘http://foo.bar.com/services/

logon_service = SOAP::RPC::Driver.new(base + ‘LogonService?wsdl’, nil)
logon_service.add_method(‘login’, ‘username’, ‘password’)
logon_service.login(‘foo’, ‘bar’)

do_stuff_service = SOAP::RPC::Driver.new(base + ‘DoStuffService?wsdl’, nil)
do_stuff_service.add_method(‘getThing’)
do_stuff_service.getThing()

This logs in to the first service okay, but calls to DoStuffService fail
with ‘not logged in’. I assume this is because the login/session details
are maintained by cookies and so I need to invoke both services from the
same driver.

Isn’t the service a kind of “logging-in with user/passwd to get a session
token then passing the token with all methods”, is it?

When the service uses http-cookies as you mention, you must use http-access2
instead of net/http (net/http does not support http-cookies as a first class),
and must call some internal method (not out-of-box support for now).

What version are you using?

  1. ruby/1.8.1 + bundled soap module
  2. ruby/CVS HEAD + bundled soap module
  3. soap4r/1.5.2
  4. soap4r/CVS HEAD

I just cant figure out how to tell each method to use which service (i.e…
namespace) …

Should I be using add_method_with_soapaction?

Yes. Or simply create a new driver.

Regards,
// NaHi