Simple Web Service

I'm trying to write my first web service, essentially it's "hello world".

I have an api:

class BackendApi < ActionWebService::API::Base   api_method :test,    :returns => [[:string]] end

a service controller:

class BackendController < ApplicationController   wsdl_service_name 'backend'   web_service_scaffold :invoke

  def test      return ["hello","world"]   end end

and a client controller

class DrawingsController < ApplicationController

web_client_api :backend, :soap, "http://localhost:3000/backend/api&quot;   def index   x = backend.test   render_text "success"   end end

As you can see from above this is running locally, and on a Webrick server. If I exercise the service using http://localhost:3000/backend/invoke it works fine. However if I use the client, as in http://localhost:3000/drawings (using the index), it just times out:

Here's the trace: /usr/lib/ruby/1.8/timeout.rb:54:in `parse_header' /usr/lib/ruby/1.8/timeout.rb:56:in `timeout' /usr/lib/ruby/1.8/timeout.rb:76:in `timeout' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:1464:in `parse_header' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:1422:in `read_header' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:1254:in `get_status' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:466:in `do_get_header' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:436:in `do_get_block' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:370:in `conn_request' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:285:in `request' /usr/lib/ruby/gems/1.8/gems/rubyforge-0.3.1/lib/http-access2.rb:264:in `post' /usr/lib/ruby/1.8/soap/streamHandler.rb:170:in `send_post' /usr/lib/ruby/1.8/soap/streamHandler.rb:109:in `send' /usr/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route' /usr/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call' /usr/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call' /usr/lib/ruby/1.8/soap/rpc/driver.rb:232:in `test' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/client/soap_client.rb:61:in `perform_invocation' /usr/lib/ruby/gems/1.8/gems/actionwebservice-1.1.2/lib/action_web_service/client/base.rb:15:in `method_missing' #{RAILS_ROOT}/app/controllers/drawings_controller.rb:7:in `index'

Can anyone spot what I'm doing wrong here? I'm going by the Agile book and this part is a little lite on examples.

Thanks,

Gary

<ghuntress@...> writes:

Can anyone spot what I'm doing wrong here? I'm going by the Agile book and

this part is a little lite on examples.

Thanks,

Gary

Don't worry, it's not an error you could really have predicted. The problem is webrick's.

Webrick can only support one concurrent connection, whereas your scenario depends on having two connections processed simultaneously - the request you make to your browser and the internal request the SOAP client is making.

The browser request is made first, but can't finish until the internal request finishes, however the internal request can't be handled until the browser request is dealt with. Deadlock.

The simplest way around it is to run another server and have your SOAP requests pointed at there instead.ea

Gareth