Hi all, I''m trying to build a simple SOAP interface to http://tiny.carldr.com/. I think I have the server side set-up OK, the API can be seen at http://test.tiny.carldr.com/url/service.wsdl My client is simply : require ''rubygems'' require ''action_web_service'' class UrlApi < ActionWebService::API::Base api_method :shorten, :expects => [ { :long_url => :string } ], :returns => [ :string ] end url = ActionWebService::Client::Soap.new( UrlApi, "http://test.tiny.carldr.com/url/api" ) puts url.shorten( "http://www.carldr.com/" ) However, it doesn''t work! When I run the above script, I get an error on the server : Processing UrlController#api (for 127.0.0.1 at Tue Mar 15 19:43:07 GMT 2005) Parameters: {"<?xml version"=>"\"1.0\" encoding=\"utf-8\" ?>\n<env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <env:Body>\n <n1:Shorten xmlns:n1=\"urn:ActionWebService\"\n env:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n <long_url xsi:type=\"xsd:string\">http://www.carldr.com/</long_url>\n </n1:Shorten>\n </env:Body>\n</env:Envelope>", "action"=>"api", "controller"=>"url", "url/api.html/api"=>nil} TypeError (can''t modify frozen string): /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/pr otocol/soap_protocol.rb:49:in `gsub!'' ... Rest of backtrace snipped. ... I also get an error on the client once the above has happened, but I''m presuming it''s a problem on the server side. Any idea what I''m doing wrong? Any pointers gratefully received! Regards, Carl.
On Tue, 15 Mar 2005 19:40:52 -0000, carl <carl-CZ32reIrJxPQT0dZR+AlfA@public.gmane.org> wrote:> TypeError (can''t modify frozen string): > > /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/pr > otocol/soap_protocol.rb:49:in `gsub!'' > ... > Rest of backtrace snipped.This is interesting. It exposes a flaw in AWS, in that its modifying values in @request.env directly instead of copying them first. But over here, values in @request aren''t frozen. What version of Ruby are you running? I''ll need the full version (gotten by running "ruby -v") including the date. Thanks, Leon
Hi Leon,> This is interesting. It exposes a flaw in AWS, in that its > modifying values in @request.env directly instead of copying > them first. But over here, values in @request aren''t frozen. > > What version of Ruby are you running? I''ll need the full > version (gotten by running "ruby -v") including the date.I''m running "Ruby 1.8.2 (2004-12-25) [i386-linux]". I noticed a changeset just posted by David, and applying that has changed the error to something that looks more like something I''m doing wrong, but I can''t find out what. The error I''m getting now is : /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di spatcher/abstract.rb:37:in `shorten'': wrong number of arguments (0 for 1) (ArgumentError) from /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di spatcher/abstract.rb:37:in `__send__'' from /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di spatcher/abstract.rb:37:in `web_service_direct_invoke_without_controller'' ... Snipped ... The server is getting the request properly, and I''m verified my signature is correct. Is there something else I''ve forgotten to check or do? Regards, Carl.
On Tue, 15 Mar 2005 22:20:19 -0000, carl <carl-CZ32reIrJxPQT0dZR+AlfA@public.gmane.org> wrote:> /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di > spatcher/abstract.rb:37:in `shorten'': wrong number of arguments (0 for 1) > (ArgumentError) > from > /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di > spatcher/abstract.rb:37:in `__send__'' > from > /usr/lib/ruby/gems/1.8/gems/actionwebservice-0.6.0/lib/action_web_service/di > spatcher/abstract.rb:37:in `web_service_direct_invoke_without_controller'' > ... > Snipped > ... > > The server is getting the request properly, and I''m verified my signature is > correct. Is there something else I''ve forgotten to check or do?Hi Carl, This looks like you are using direct dispatching mode, but still declared the method in the controller like this: def shorten(arg) end When using direct dispatching, methods are invoked using ActionPack action conventions, with method parameters being provided in @params (keyed by parameter name), or @method_params. Only when using delegated dispatching (i.e. the service is implemented by a seperate service class outside of the controller), do you use the standard def method(args) syntax. See: http://manuals.rubyonrails.com/read/chapter/69 For an overview and examples. Leon