Chapter 3. Building Web Service Servers with Ruby on Rails

In the first section, I covered the basics of building clients for the three most poplar web service types (REST, XML-RPC, and SOAP). Now it's time to get down to the really interesting stuff: building web service servers! I'll once again cover the three most popular formats for web services: REST, SOAP, and XML-RPC. I'll also provide working examples to demonstrate each concept and give you a head start on building your own services.

REST-Based Web Service Server Serving Proprietary XML Documents

REST—for our purposes—is really the same thing as a simple web GET request: it requires no special server setup or request encoding and decoding. You simply use your favorite web server and serve your results in whatever format you choose to design—usually a custom XML format. Regardless of the implementation language, most developers agree that REST services are simple to build and flexible enough to adapt to your needs. Additionally, if you closely adhere to the true intent of REST, you can take advantage of any HTTP-based filters and security measures your server has in place. Because of these types of benefits, and REST's simplicity, most of the web services out in the "real world" are REST services, rather than SOAP or XML-RPC services.

When it comes to Rails applications, RXML templates help make it simple to build REST-based servers with custom XML documents. In fact, to build REST-based web servers with Ruby on Rails, ...

Get Web Services on Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.