Skip Navigation Links

Pumped on REST

Posted by gcuomo on August 4th, 2007. Other posts by gcuomo

Let me say a little more on REST

Folks have been asking me about why I’m so excited about REST. Specifically, I’m asked how REST can help one implement a Service Oriented Architecture. REST is a style of architecture that is best exemplified within the HTTP protocol. Project Zero follows this style of REST. In Zero, REST is realized via its implementation of HTTP-based events, naming and directory conventions and utility libraries.

I strongly feel that REST enables the creation of web services that are simple to implement, built for re-use, and are ultra-scaleable. So, please let me elaborate:

Simple to Implement:

Creating a RESTful web service is like forming a Sentence; you need a Noun, a Verb and an Adjective. Simple Enough. In REST terms, Nouns are the Resources pointed to by URLs. The Verbs are the HTTP Actions on resources. The Adjectives (okay, this might be a little stretch), are the formats of data that the Resources are represented in. We like to lay this out in tables similar to the way we broke down sentences in grade school. For example, here is how we would describe a set of services related to a Photo Album application:

Sentence
Resource Description
Noun
URI
Verb
HTTP Action (Zero Event)
Adjectives
Formats
List all the Albums. …/album GET (onList) JSON
Show a JPEG Photo. …/photo GET (onRetreive) JPEG
Add a JPEG Photo. …/photo POST (onCreate) JPEG
Delete a JPEG Photo. …/photo DELETE (onDelete) JPEG
List all the JPEG Photos. …/photo GET (onList) JPEG

Some explanation.

  • Nouns/URIs – URLs are the most identifiable part of the web, and as such really straight forward way of organizing your services. Organizing a unique URI for each resource avoids confusion and promotes scalability.
  • Verbs/Actions – You can perform exactly 4 HTTP operations on these URLs. POST, GET, PUT and DELETE. (HTTP supports a few more actions, but these are the interesting ones for now). While constraining, the simplicity is somewhat liberating. These operations roughly map to Create, Read, Update and Delete (CRUD). Heck, CRUD provides the foundational functions needed to implement a relational database, so I think while simple; these 4 methods can be used in interesting and powerful ways. In the table, I also included the Zero Event that gets triggered when a URL, with the given action is received. Reponding to these actions in Zero feels a little like programming in VB or JavaScript. (i.e., OnXXX events).
  • Adjectives/Data Formats – There are well known data types (MIME types. Eg., text/html, image/jpeg)) that are natively supported by HTTP servers and browsers. Simple XML and JSON allow more custom data formats, that are both self describing and can easily be parsed by the user (When I say parse I also mean read with your eyes and parse with your brain.)

Built for Reuse:

With the Sentence metaphor as a basic building block, we can build on the RESTful service model and add new metaphors like Feeds. The Zero environment supports the ATOM feed technology that allows a user to create, update and subscribe to a Resources. Restful Feeds open up an interesting realm of possibilities. New Feeds can be composed, form existing feeds and tailored, merged, sorted, filtered to provide a custom “skin” for your web services. The Zero Assembly Fabric provides a set of APIs and utilities to manipulate Feeds.

Ultra-Scaleable

The scalability of the HTTP and the web is well documented. The Sentence approach to web services allows standard HTTP server features to be used to optimize, secure and scale your services. For example, commodity HTTP caching proxies, firewalls and routers can be effectively used with your application without requiring special knowledge of your application or implementation platform.

There are many other descriptions of REST in the Blogosphere. I particularly like the discussion around REST found on the REST Wiki. Bitworking.org describes a RESTful recipe for creating web services that fits perfectly with the Zero approach to REST.

One Response to “Pumped on REST”

  1. Project Zero » Blog Archive » Restful SOA Says:

    [...] will elaborate on this point in other blog entries. My Pumped on REST entry is a continuation on this RESTful SOA [...]

Leave a Reply