Rey9999
(Rey9999)
1
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:
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.
<snip>
From one n00b to another 
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
Rey9999
(Rey9999)
3
Thank you!
I'll try as soon as possible.
that should be :expects => [{:name => :string}, {:password => :string}]
then you should be able to just do @ws_client.login('user', 'password')
Fred
Rey9999
(Rey9999)
5
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