Uninformed

The industry mainstream has now heard of REST, but not everyone gets it yet. Example: this Directions article.

When writing about REST, the most important things to communicate are the central tenets. Tim Bray explains them like this:

  • You have a lot of things in the system, identified by URIs.

  • The protocol (probably HTTP) only knows one MEP [message exchange pattern]: single-request, single-response, with the request directed at a URI.

  • An important subset of the requests, what HTTP calls GET, are read-only, safe, idempotent.

  • You expect to ship a lot of URIs around in the bodies of requests and responses, and use them in operations that feel like link following.

Andrews doesn't address the tenets and, instead, muddles around with "GET URLs" and "POST URLs" in an article that misinforms readers. Most of what's wrong in the article is summarized in the first sentance of the closing paragraph (emphasis mine):

Until then, I don't have much of an opinion about whether the industry should standardize on POST or GET request types. Both types of request use predictable, standardized formats that can be executed elegantly or poorly. The REST discussion reveals that the industry should consider that predictability is not the only goal of standards. Intuitiveness and accessibility may be equally important when establishing information exchange standards.

In reality, there's no such controversy. A RESTful GIS web service uses both POST and GET: the former to create new web resources, the latter to fetch representations of resources in a safe (no side-effects) way.

Comments

Re: Uninformed

Author: Chris Andrews

Sean, I don't disagree with you... but how do you explain particle physics before first explaining addition. I would encourage you to better describe the issue to help inform the general GIS audience. Thanks for the feedback. Chris

Re: Uninformed

Author: Sean

Luckily, grokking REST is a lot easier than understanding quantum field theory. Starting from zero, the first thing to explain to someone is: With REST, every piece of information has its own URL. Once they get this, move on to explaining the tenets of REST in engineering terms like Bray did (above). If you've still got an audience, get into the details of representation formats, resource modeling, and PUT.

Re: Uninformed

Author: Allan Doyle

Or maybe we're not looking for engineering terms here... First, the term "web" means that you are interacting with things using HTTP, a protocol most people are familiar with only through their browsers. Generally, HTTP in a browser uses "GET" to fetch HTML, but can also be used to do a lot more. Also, generally, "POST" is used to push information back to a server/service. There are other common but lesser-known operations, "PUT" and "DELETE". REST is a style of interaction that constrains the way these four "verbs" are used during a web-based interchange. That means that not all possible uses of "GET" are considered to be proper uses. In particular, any use of "GET" should always result in pulling information from a server. Thus it's non-RESTful to use "GET" to push information back to the server that changes the state of the server. For that you should use POST, PUT, or DELETE. When you use your browser to access something like http://finance.google.com/finance?q=AAPL you expect to get back the Google finance page for Apple. You could conceivably also set things up so that the NASDAQ could use http://finance.google.com/finance?q=AAPL&current=136.82 to update the stock price. Well, if they do that using "GET", that's not REST. REST says that if you want to update a resource (in this case, the price of Apple stock) you should use the HTTP PUT operation. (Note that REST would also favor the use of http://finance.google.com/finance/AAPL instead, but that's a more subtle point) And, let's say I get my company, RESTfulServicesInc, listed after my wildly successful IPO, then a RESTful way to initialize the new listing would be by using HTTP POST of the initial information to http://finance.google.com/finance/. And, sadly, when my company tanks, I use DELETE. So REST talks about verbs (GET, POST, PUT, DELETE) and specifies how each of those should be used. It's like me telling you never to hammer nails with the handle of a screwdriver. Sure, you can do it, but it's not going to follow the generally accepted constraints of carpentry. REST also talks about the use of other parts of HTTP, such as how to use the "header" information that is transferred with each of the four verbs. Why does all this matter? Adherents of REST say that by accepting the constraints REST imposes on the use of the HTTP verbs, you can build more robust web services and that those web services will, in fact, work properly with the existing mechanisms of the web, including things generally hidden to end-users like proxies and caches. Furthermore, they say that using non-REST (SOAP, WS-*, or just a general mish-mash of HTTP), systems are more prone to failure over the long term. Ultimately it boils down to some simple questions of style. Do you prefer to work with a more tightly coupled interaction between client and server that is influenced by the previous generations of client/server frameworks like DCE, CORBA, OLE/COM, etc. (which is really a distributed computing platform added on top of HTTP as a separate layer) or do you prefer to work with a a style of interaction that uses HTTP as the actual layer of interaction. REST is the latter.

Re: Uninformed

Author: Sean

Beautiful, Allan. I like the carpentry analogy for REST constraints.