N00b question on passing parameters to a webservice

Let us say I have a webservice method:
api_method :login, :expects =>
[:name=>:string, :password=>:string], :returns => [:int]

defined as:

def login(name, password)

#do something here and returns an int
end

how do exacly pass it the two parameters from the client?
I tried:

  • @ws_client.login(‘user’, ‘mypwd’)

  • @ws_client.login({:name =>‘user’, :password=>‘mypwd’})

  • @ws_client.login([‘a’,‘b’])

No matte what, I always get:
“wrong number of arguments (1 for 2)”

When edit the method to accept just one parameter, and call it with:
@ws_client.login(‘user’)
everything runs fine.

I’m sure I’m missing something very obvious. Please help…

Thanks in advance

Rey9999

Rey9999 wrote:

“wrong number of arguments (1 for 2)”

When edit the method to accept just one parameter, and call it with:
@ws_client.login(‘user’)
everything runs fine.

From one n00b to another :wink:

Have you tried this?

@ws_client.login(:name =>‘user’, :password=>‘mypwd’)

I would have thought this would have worked (I don’t know why it
doesn’t):

@ws_client.login(‘user’, ‘mypwd’)

…but these won’t work :

@ws_client.login({:name =>‘user’, :password=>‘mypwd’})

@ws_client.login([‘a’,‘b’])

…because Ruby sees the Hash and Array as a single argument

Thank you!
I’ll try as soon as possible.

On 22 May 2008, at 13:16, Rey9999 wrote:

Thank you!
I’ll try as soon as possible.

On 22 Mag, 12:20, Rory McKinley [email protected] wrote:

Rey9999 wrote:

Let us say I have a webservice method:
api_method :login, :expects =>
[:name=>:string, :password=>:string], :returns => [:int]

that should be :expects => [{:name => :string}, {:password => :string}]

then you should be able to just do @ws_client.login(‘user’, ‘password’)

Fred

Ok, the lucky combination was:

:expects => [{:name => :string}, {:password => :string}] #in the
service definition

@ws_client.login({:name =>‘user’, :password=>‘mypwd’}) # in the method
call.

Now it works beautifully.
Thanks a lot, everyone!

Rey9999