ActionWebService for many APIs in rails?

Hi,

We’ve a pretty large rails application and we are currently deciding
moving a part of the application front-end to a desktop GUI.

For communication between application and GUI we decided to use an API.
So basically what I need is a way to have our models functionality
accessible by the GUI.

The basic idea:

Rails app provides API for models <-> HTTPS Connection <-> GUI can
access models with correct authentication

I took a look to ActionWebservice, but I’m not sure if this is the best
solution.

My concern: The application has currently about 90 models. If I
understood AWS correctly, I need to create an API class for every model
and a ‘service’ for every model I want to serve?

Is there an automation script for this or is there a more direct
approach to my problem ?

Thanks!

You create just one class API

dir: RAILS_ROOT/app/apis/myserver_api.rb
class MyserverApi < ActionWebService::API::Base
api_method :list_products,
:expects => [:string],
:returns => [:string]

api_method :list_users,
            :expects => [:string],
            :returns => [:string]

api_method :list_orders,
            :expects => [:string],
            :returns => [:string]

end

dir: RAILS_ROOT/app/controller/myserver_controller.rb
class MyserverController < ApplicationController
wsdl_service_name ‘Myserver’
web_service_api MyserverApi

def list_products(str)
end

def list_users(str)
end

def list_orders(str)
end

end

In the api you put all the method that are in the controller and after
you use
your models inside your controller. You can do the job with one API
class definition or you split in more for how many controllers you
have.

Or if you already have your controllers done, you just need to write
some API

2007/6/19, joaz [email protected]:

api_method :list, :returns => [[:string]]

with this returns an array with one record for each row

2007/6/19, joaz [email protected]:

Or if you already have your controllers done, you just need to write
some API
Wenn 95% of all controller actions just grabs some data like

def list
@people = Person.find(:all)
end

I tried something like this:
api_method :list, :returns => [[Person]]

But I get an error when accessing via invoke using the SOAP protocol:
“decimal is not a valid base type” on numeric fields in our postgresql
database.

claudio wrote:

api_method :list, :returns => [[:string]]

with this returns an array with one record for each row

well in my case this returns an array with Object.to_s
["#Person:0xb701e23c", “#Person:0xb701e0d4”,…]