views:

631

answers:

2

Hello

I am getting an error when trying to access a web service via soap

soap_client = SOAP::WSDLDriverFactory.new("http://api.upsidewireless.com/soap/Authentication.asmx?WSDL")
driver = soap_client.createDriver
@p = driver.GetParameters(:username => 'uname', :password => 'pword') #ERROR => wrong number of arguments (1 for 2)

I can clearly see two arguments for this method call. Why would I be getting this error?

+2  A: 

WSDLDriver is deprecated (called from createDriver). You should use 'create_rpc_driver'. I get back a response with that method from your example. Is there some reason not to use 'create_rpc_driver' ?

james
No there was no specific reason. I guess I was working off an older example. Your solution works. Thank you
rube_noob
+4  A: 

@james has the right answer, but just for future reference (and because this has bitten me before), this call:

driver.GetParameters(:username => 'uname', :password => 'pword')

is passing one parameter: a hash. Each of your elements isn't one thing; it's a hash element with a key and a value. Ruby notices this and puts them all into one hash. So you are effectively passing this:

driver.GetParameters({:username => 'uname', :password => 'pword'})

This is one of the confusing things about calling a method in Ruby. If you pass a hash as the last (or only) parameter, you can leave off the {}, and most people do. Makes it hard to figure out sometimes.

If you actually wanted to pass this as two parameters:

driver.GetParameters('uname', 'pword')
Sarah Mei
Thanks, This is very useful. I've wondered about why I would get some error messages for 1 for 2 arguments.
Tilendor