<noobalert> Uh, yeah. So my noob self is showing through again. I''m trying to write a simple hello-world type web service with the ActionWebService thingy. I didn''t get very far. I''ve only done web services stuff in .NET, so I''m not exactly used to this sort of thing. Anyhow, I have a file, person_api.rb in my app/apis folder. I want to take a single string as a parameter, and return an array of strings. I''m not sure if I got the method signature stuff correct. My current code for the app/apis/person_api.rb file is like this: class PersonAPI < ActionWebService::API::Base inflect_names false api_method :friends, :returns => [[:string]], :expects => [ {:mboxhash => :string} ] end And then in my app/controllers/person_controller.rb file I have: class PersonController < ApplicationController layout "xhtml11common", :except => :foaf def show @person = Person.find @params["id"] if @session["currentperson"] != nil @currentperson = Person.find @session["currentperson"] end end def foaf @person = Person.find @params["id"] end # web service method def friends return ["helloworld_" + @params[''mboxhash'']] end end A) is this correct? B) if it is, why do I keep getting "Internal protocol error" when I visit http://scutter.us/person/api or http://scutter.us/person/api/friends ? I''m kinda used to just navigating to foobar.asmx and getting a nice autogenerated interface that I can use to make sure my web service is doing what I expect. </noobalert> -- Bob Aman
On Thu, 24 Feb 2005 16:41:50 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> My current code for the app/apis/person_api.rb file is like this: > > class PersonAPI < ActionWebService::API::Base > inflect_names false > > api_method :friends, :returns => [[:string]], :expects => [ > {:mboxhash => :string} > ] > endThis looks fine. What do you get when you navigate to /person/service.wsdl? You should be getting WSDL that contains a ''Friends'' method.> B) if it is, why do I keep getting "Internal > protocol error" when I visit http://scutter.us/person/api or > http://scutter.us/person/api/friends ? I''m kinda used to just > navigating to foobar.asmx and getting a nice autogenerated interface > that I can use to make sure my web service is doing what I expect.That kind of interface isn''t implemented yet :) Currently AWS only supports POST requests to the /person/api URL. Please file a feature request against ActionWebService for the GET interface to support this kind of "web service scaffolding". However, you should be able to test it realtime like this: $ ./script/console Loading development environment.> require ''person_api'' > client = ActionWebService::Client::Soap.new(PersonAPI, ''http://scutter.us/person/api'') > client.friendsYou can verify that the requests are arriving at the server by checking the log, as AWS logs the XML request and response. I''m interested in lessening any pain, so please let me know where it hurts :) Leon
> This looks fine. What do you get when you navigate to > /person/service.wsdl? You should be getting WSDL that contains a > ''Friends'' method.http://scutter.us/person/service.wsdl See for yourself. It seems to be returning an empty page.> That kind of interface isn''t implemented yet :) Currently AWS only > supports POST requests to the /person/api URL. Please file a feature > request against ActionWebService for the GET interface to support this > kind of "web service scaffolding".Makes sense. Though I wouldn''t have expected "internal protocol error" as a response.> However, you should be able to test it realtime like this: > > $ ./script/console > Loading development environment. > > require ''person_api'' > > client = ActionWebService::Client::Soap.new(PersonAPI, ''http://scutter.us/person/api'') > > client.friendsok, on this line: client = ActionWebService::Client::Soap.new(PersonAPI, ''http://scutter.us/person/api'') I get this: NoMethodError: undefined method `[]'' for SOAP::SOAPString:Class from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:289:in `lookup'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:334:in `map_api'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:333:in `call'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:359:in `map_api'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:356:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:356:in `map_api'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:351:in `each'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/protocol/soap_protocol.rb:351:in `map_api'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/client/soap_client.rb:51:in `create_soap_rpc_driver'' from /usr/local/lib/ruby/gems/1.8/gems/actionwebservice-0.5.0/lib/action_web_service/client/soap_client.rb:37:in `initialize'' from (irb):4:in `new'' from (irb):4 -- Bob Aman
On Thu, 24 Feb 2005 18:11:18 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Makes sense. Though I wouldn''t have expected "internal protocol > error" as a response.That will be fixed.> I get this: > NoMethodError: undefined method `[]'' for SOAP::SOAPString:ClassWhich version of Ruby are you running? That error seems to be the result of a behavioural change in the underlying SOAP bindings for Ruby. In 1.8.2 final, the object being indexed is always returned by the bindings as an Array, but in your version, its a SOAP::SOAPString. I think I can work around it, but I''d need to test on your version of Ruby too. Thanks Leon
> That will be fixed.Cool.> > I get this: > > NoMethodError: undefined method `[]'' for SOAP::SOAPString:Class > Which version of Ruby are you running? That error seems to be the > result of a behavioural change in the underlying SOAP bindings for > Ruby. In 1.8.2 final, the object being indexed is always returned by > the bindings as an Array, but in your version, its a SOAP::SOAPString. > > I think I can work around it, but I''d need to test on your version of Ruby too.I''m using 1.8.2. -- Bob Aman
On Thu, 24 Feb 2005 20:05:42 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using 1.8.2.Right, I think I know what the problem is. Someone else who also has a TextDrive account was able to do some testing for me, and his Ruby build was 2004-07-29, perhaps this is your problem as well. I tested against 1.8.2 final (2004-12-25) on FreeBSD 5.3, and it works, and so the change in behaviour must have occurred after your build. Thing is, in 1.8.2 final that array crucially contains some additional information that is necessary for correct WSDL generation, and from the Ruby changelog, some significant updates to SOAP. If you the guys at TextDrive can upgrade you to 2004-12-25, it should work. I''ll see if I can track down that particular Ruby build snapshot though and come up with a workaround. Thanks for the report! Leon
On Fri, 25 Feb 2005 14:59:50 +1300, leon breedt <bitserf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, 24 Feb 2005 20:05:42 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m using 1.8.2. > Right, I think I know what the problem is. Someone else who also has a > TextDrive account was able to do some testing for me, and his Ruby > build was 2004-07-29, perhaps this is your problem as well. > > I tested against 1.8.2 final (2004-12-25) on FreeBSD 5.3, and it > works, and so the change in behaviour must have occurred after your > build. > > Thing is, in 1.8.2 final that array crucially contains some additional > information that is necessary for correct WSDL generation, and from > the Ruby changelog, some significant updates to SOAP. > > If you the guys at TextDrive can upgrade you to 2004-12-25, it should > work. I''ll see if I can track down that particular Ruby build snapshot > though and come up with a workaround. > > Thanks for the report! > LeonIs there any way to make the system more intellegent about whether it''s dealing with an Array or a SOAPString? The version problem could be avoided if it just detects which its dealing with and handles it appropriately, right? I also opened a support ticket with TextDrive on the matter. -- Bob Aman
On Thu, 24 Feb 2005 22:17:25 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there any way to make the system more intellegent about whether > it''s dealing with an Array or a SOAPString? The version problem could > be avoided if it just detects which its dealing with and handles it > appropriately, right?In the current version AWS version, possibly. But in the upcoming version of AWS, this particular quirk is going to cause problems due to a change in the way we use SOAP. To cut a long explanation short, we''re using more of the public SOAP API, in order to do faster and more correct marshaling and unmarshaling of custom types. I''m not too happy with having special cases for multiple versions of 1.8.2 (!!), I''d have hoped I could rely on return values being the same for a given Ruby core version, but I suppose supporting any 1.8.2 version of SOAP is a reasonable goal. Regards Leon
On Fri, 25 Feb 2005 21:50:36 -0500, Bob Aman <vacindak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, so TextDrive upgraded their version of Ruby, but now I''m having > trouble running those irb commands again. > > I keep getting undefined method `header'' for nil:NilClassThis is a bug that has since been fixed in Subversion (http://dev.rubyonrails.com/changeset/798): If the method being called throws an exception, no response is returned to the caller (which is incorrect for the SOAP protocol). If you look in log/development.log, you should see stack trace for the exception thrown by your code in the log, followed by a stack trace for an exception in action_controller_dispatcher.rb. To fix it, changing this line in action_controller_dispatcher.rb: logger.debug("\nWeb Service Response (%f):" % elapsed) To this line: logger.debug("\nWeb Service Response" + (elapsed ? " (%f):" % elapsed : ":")) I''m sorry that you''ve been experiencing these problems, the next version will include much more useful debugging information that will be sent to the client whether errors occur in your API or a bug in AWS causes an exception. For now, when you get this message, check the log files for the real exception. Regards Leon