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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rory McKinley
2008-May-22 10:20 UTC
Re: n00b question on passing parameters to a webservice
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you! I''ll try as soon as possible. On 22 Mag, 12:20, Rory McKinley <rorymckinleyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-22 13:01 UTC
Re: n00b question on passing parameters to a webservice
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 <rorymckinleyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On 22 Mag, 15:01, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 <rorymckinleyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---