1.16. Action Web Services

Rails allows for rapid development of web services. Web services can be broken down into two main parts: servers and clients. Servers provide the service that is being accessed, and the clients are the applications that access them. Most web services are based on one of three architectures: REST, XML-RPC, or SOAP.

1.16.1. What Can You Do with Web Services Under Rails?

There are many web services available for you to use, from Yahoo! Search to Flickr to everything in between. Visit http://www.programmableweb.com/apis for hundreds of useful web service providers. For additional information on web services using Rails, I suggest reading Kevin Marshall’s Short Cut: Web Services on Rails at http://www.oreilly.com/catalog/9780596527969.

1.16.2. Using REST

REST is often referred to as the simplest web service architecture. For the most part, REST is operations work just like standard webpage requests. The main advantages of using REST over XML-RPC or SOAP are:

  • It is lightweight—not a lot of extra XML markup

  • It produces human-readable results

  • It is easy to build—no toolkits required

REST is rapidly becoming the web service framework of choice and is now being used by all of Yahoo!’s web services, including Flickr. del.icio.us API, bloglines, technorati, eBay, and Amazon use it as well.

The following is a step-by-step example of how to use Yahoo! Search REST API. For this example to work, you will need an application ID. Register at http://api.search.yahoo.com/webservices/register_application ...

Get Rails Pocket Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.