Wednesday, July 18, 2007

REVIEW: RESTful Web Services

Sam Ruby and Leonard Leonard Richardson have written an excellent introduction to the world of RESTful Web Services - web services that work like the rest of the Web. While I was reading this book several people commented that the books "is just the HTTP Standard" so clearly there is a need for this book. REST is an architectural model for designing web services within the HTTP specification and maintaining the spirit of the Web by keeping the focus on resources. By contrast, SOAP complies with the HTTP specification but uses it as a generic transport layer because SOAP was designed to be used by other transports like SMTP or Messaging Queues - this approach has it's pluses and minuses (mostly minuses).

The book begins with an overview of how HTTP works with an emphasis on the resource aspects of the web and how the different verbs (GET / PUT / POST / DELETE) operate on resources. This is followed by an analysis of various commercial services (, flickr, S3) and how they measure up to the RESTive ideals - the book does a reasonable job of defining REST thru counterexample without being too preachy.

The real meat of the book is the chapter on Resource Oriented Architecture which defines concrete rules for designing a resource centric API and how the uniform interface (the standard HTTP verbs) act open them. The authors make the point that one of the primary reasons that remote procedure call interfaces (like SOAP and XMLRPC) are so seductive is that they make it easy to take an existing legacy system and web service enable it. By contrast, Resource Oriented Architecture requires that the entire system be designed around resources and the manipulations on them - and it's hard for vendors to sell tools that do this sort of thing. However, it's a lot more likely that a service that has been designed around resources will work well on the web. The book goes through some examples of applying this architecture in various scenarios, covering some common problems like how to model transient resources for things like transactions.

One of the parts of the book I really liked are the appendices which cover all of the HTTP response codes and request / response headers. While all of this is covered in various specifications, the book goes into some detail of all the codes, when (if at all) they are likely to be seen and common pitfalls.

Overall the book is excellent - it is very much a practical guide to web services rather than an academic book. Like practicing Feng Shui, producing a perfectly RESTful application may not always be possible but applying the principles to any extent will result in better web services. One of the key points is that the web sites that end users interact with are also RESTful web services and many of the design principles of resource oriented architecture will also result in better web sites.


Post a Comment

<< Home