# Using ActionWebService with Edge Rails/Rails 2.0

**URL:** <https://www.ruby-forum.com/t/using-actionwebservice-with-edge-rails-rails-2-0/121408>\
**Category:** Rails\
**Created:** [November 27, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/using-actionwebservice-with-edge-rails-rails-2-0/121408 "2007-11-27T18:57:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliotb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@elliotb](https://www.ruby-forum.com/u/elliotb)\
**Post date:** [November 27, 2007, 6:57pm UTC](https://www.ruby-forum.com/t/using-actionwebservice-with-edge-rails-rails-2-0/121408/1 "2007-11-27T18:57:44Z")

</div>

Hi

We have a Rails app running Edge Rails R8041, serving up a RESTful API  
and have recently had the need arise to add a SOAP API. After a bit of  
fighting with load paths setting the following in environment.rb:

config.load\_paths += %W( #{RAILS\_ROOT}/vendor/rails/actionwebservice/lib  
)  
config.load\_paths += %W( #{RAILS\_ROOT}/app/apis )

we had a quick controller running serving up a simple search facility,  
located in /app/controllers/api/clients\_controller.rb with the following  
content:

class Api::ClientsController \< ApplicationController  
session :off  
web\_service\_dispatching\_mode :delegated  
web\_service :clients, ClientsService.new  
end

There was then a corresponding API file in /app/apis/clients\_service.rb  
containing:

class ClientsAPI \< ActionWebService::API::Base  
inflect\_names false  
api\_method :search, :expects =\> [{:query =\> :string}], :returns =\>  
[[Client::MiniClientRecord]]  
end

class ClientsService \< ActionWebService::Base  
web\_service\_api ClientsAPI  
def search(query)  
return [] if query.blank?  
return Client.search(query).collect {|c| c.to\_client\_record(true) }  
end  
end

We also have a number of other services set up.

This all works as expected when running in development mode, but when  
switching to production mode, or just enabling cache\_classes=true in the  
development environment, the services cannot be accessed, instead you  
get a 404 saying no action responded to clients. The WSDL still works in  
production mode.

We thought this may be an issue with having the controllers in the  
nested API folder, but moving them into the root controllers folder  
produced the same issue. Removing similar named unnested controllers  
(i.e. /controllers/clients\_controller.rb) also failed to work.

Does anyone have any insight into why these are not working, or could  
share details of how they are running and configuring Rails 2 with  
ActionWebService? It seems the documentation is now way out of date  
since it has been removed from the core rails package, and DHH’s promise  
of it just being as simple as re-including AWS doesn’t quite ring true.

Regards,

Elliot

---

<div class="post-metadata">

**Author:** ![elliotb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@elliotb](https://www.ruby-forum.com/u/elliotb)\
**Post date:** [November 27, 2007, 6:59pm UTC](https://www.ruby-forum.com/t/using-actionwebservice-with-edge-rails-rails-2-0/121408/2 "2007-11-27T18:59:33Z")

</div>

I forgot to mention, switching to layered dispatching resulted in a  
similar message, but saying no action responded to rpc, and switching to  
direct dispatching did not work at all.

Thanks again,

Elliot

---

<div class="post-metadata">

**Author:** ![elliotb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/7993a0/32.png) [@elliotb](https://www.ruby-forum.com/u/elliotb)\
**Post date:** [January 3, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/using-actionwebservice-with-edge-rails-rails-2-0/121408/3 "2008-01-03T21:45:26Z")

</div>

Did you ever figure out what was going on with this? I seem to have  
the same problem. Inside the action\_controller\_dispatcher.rb file the  
following code doesn’t seem to be executed the first time the class  
loads:

```
    base.add_web_service_api_callback do |klass, api|
      if klass.web_service_dispatching_mode == :direct
        klass.class_eval 'def api; dispatch_web_service_request;

```

end’  
end  
end  
base.add\_web\_service\_definition\_callback do |klass, name,  
info|  
if klass.web\_service\_dispatching\_mode == :delegated  
klass.class\_eval “def #{name};  
dispatch\_web\_service\_request; end”  
elsif klass.web\_service\_dispatching\_mode == :layered  
klass.class\_eval ‘def api; dispatch\_web\_service\_request;  
end’  
end  
end

In cases where the class is cached, it never is executed, and never  
defines the api methods.

On Nov 27 2007, 9:59 am, Elliot Bowes \<rails-mailing-l…@andreas-
