how to write web services with RoR

The Agile Web Development book has a chapter on implementing web
services using aws.

O'Reilly Media has one of their PDF publications on it:

http://www.oreilly.com/catalog/websor/

There's a brief description here, too:

http://manuals.rubyonrails.com/read/book/10

And, while I haven't yet watched it, this video looks interesting:

http://www.bestechvideos.com/2006/12/29/ruby-on-rails-rest-web-services-with-rails/

Note that I've read that ActionWebService is being removed from the
Rails core in the next release of Rails, but is supposed to still be
available as a plugin or somesuch.

Cheers!

- - Michael W

One of the key reasons this is happening is because RESTful web
services are becoming the most popular way to do "web services" in
Rails. A good starting point is a white paper "RESTful Rails
Development"[1], and a recent O'Reilly book "RESTful Web Services"[2]
covers this territory as well, although it covers a lot more than just
Rails implementations of web services (servers or clients).

If you want to follow where Rails itself is going in this regard,
start googling for "ActiveResource", which will be a component of
Rails 2.0 that (from the viewpoint of your application) acts a lot
like ActiveRecord, but is in reality a wrapper for a remote web
service, which could be implemented in Rails or anything else.

Or, if you want to just experiment a bit with your own applications,
add something like this to the "index" method of one of your existing
application's controllers:

    def index
      @customers = Customer.find(:all) # or whatever to select the relevant rows
      respond_to do |format|
        format.html
        format.xml { render :xml = @customers.to_xml }
    end

Now, a URI like "/customers" will return the usual HTML page, but
"/customers.xml" will return the underlying data in XML format. You
can extend this concept to support (for example) JSON based Ajax
clients as well. The key message is you do *not* necessarily have to
invent a new application to return your data as a simple web service,
in addition to it being available to browser based HTML clients.

Craig McClanahan

[1] http://www.b-simple.de/documents
[2] http://www.oreilly.com/catalog/9780596529260/