RESTful is not RPC

Many Web Services claim to have a RESTful interface.  In my experience, most of these claims are false.  Here’s a clue: if your web service requires clients to POST requests with parameters serving as values to a function or procedure, then it is not restful.  And if it is based on SOAP, it is far from RESTful.

“REST” is for “REpresentational State Transfer“, perhaps the most opaque acronym ever coined.  The main characteristic of REST is that URLs identify resources.  When you issue a GET with a URL, the server returns a representation of the state of the resource.  Results from a REST request can be bookmarked, which can be problematic with non-RESTful interfaces that relay on POST and HTML forms.

As related in Wikipedia, other characteristics of a RESTful interface include:

  • A uniform interface (HTTP commands GET, PUT, POST and DELETE) is used across different applications.
  • It is stateless.
  • Representations allow a client to manipulate  a resource.
  • Messages are self-describing: they contain information describing how to process them.

An RPC-style interface is much more common than REST. With an RPC (“Remote Procedure Call”), you send the arguments to a server, and it returns a value based on on the arguments.

Back in the 90’s, I worked a lot with ONC RPC.  The transport protocol it uses  is TCP, and  XDR (eXternal Data Representation) is used to serialize program arguments and responses.  SOAP is an RPC that uses HTTP or HTTPS as the transport protocol, and XML for data encoding.  (An ironic aspect of SOAP is that initially it was an acronym for “Simple Object Access Protocol”.  This simple protocol now has a spec the width of a metropolitan phone book.)

The limiting aspect of RPC is that it requires the client to have a priori knowledge of the procedures available and the arguments they require.  RESTful interfaces do not require this level of coupling.

REST is difficult to get your head around, and I won’t pretend to have described it here.  As I’ve worked through  texts such as RESTful Web Services, by Richardson and Ruby, I’ve found that RESTful interfaces seem very inobtrusive but powerful.  This has never been my impression of a SOAP interface.


One thought on “RESTful is not RPC

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s