# How to write web services with RoR

**URL:** <https://www.ruby-forum.com/t/how-to-write-web-services-with-ror/108896>\
**Category:** Rails\
**Created:** [July 9, 2007, 4:35am UTC](https://www.ruby-forum.com/t/how-to-write-web-services-with-ror/108896 "2007-07-09T04:35:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [July 9, 2007, 4:35am UTC](https://www.ruby-forum.com/t/how-to-write-web-services-with-ror/108896/1 "2007-07-09T04:35:20Z")

</div>

Hi all

is thrre a place where I can get some information about how to write web  
services with RoR?

regards

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [July 9, 2007, 9:35am UTC](https://www.ruby-forum.com/t/how-to-write-web-services-with-ror/108896/2 "2007-07-09T09:35:28Z")

</div>

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

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

> **[Web Services on Rails](https://www.oreilly.com/library/view/web-services-on/0596527969/)**
>
> This PDF will show you how your small business or enterprise can publish its APIs (application programming interface) to a developer community just like the behemoths of the Internet--Google, Yahoo!, … - Selection from Web Services on Rails \[Book\]

There’s a brief description here, too:

[http://manuals.rubyonrails.com/read/book/10](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/](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

---

<div class="post-metadata">

**Author:** ![jsn1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7ea924/32.png) [@jsn1](https://www.ruby-forum.com/u/jsn1)\
**Post date:** [July 9, 2007, 10:05am UTC](https://www.ruby-forum.com/t/how-to-write-web-services-with-ror/108896/3 "2007-07-09T10:05:30Z")

</div>

On 7/9/07, Michael W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [snip]  
> 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.  
> [/snip]

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](http://www.b-simple.de/documents)  
[2] [http://www.oreilly.com/catalog/9780596529260/](http://www.oreilly.com/catalog/9780596529260/)
