Search
Lori MacVittie - Two Different Socks
You are here: DevCentral > Weblogs

posted on Tuesday, March 02, 2010 4:04 AM

Coffee Mug - Far Side Damned if You Do Dont A recent blog on EBPML.ORG entitled “REST 2010 - Where are We?” very aggressively stated: “REST is just a "NO WS-*" movement.” The arguments presented are definitely interesting but the most compelling point made is in the way that REST APIs are constructed, namely that unlike the “ideal” REST API described where HTTP methods are used to define action (verb) and the path the resource (noun), practical implementations of REST are using a strange combination of both actions (verbs) and resources (nouns) in URIs.

What this does is simulate very closely SOA services, in which the endpoint is a service (resource) upon which an action (method) is invoked. In the case of SOAP the action is declared either in the HTTP header (old skool SOAPaction) or as part of the SOAP payload. So the argument that most REST APIs, in practice, are really little more than a NO WS-* API is fairly accurate.

In “REST != HTTP “ Ted Neward very convincingly argues that the problem isn’t that most “REST” APIs aren’t REST (based on the definition and constraints set down by Fielding in the first place) but that folks are calling them REST despite the fact that they aren’t. That’s not necessarily the developer’s fault and, in the cases pointed out it’s quite possible that the decision to call the API a RESTful API was made by someone other than the developer.

The fact is that there are artificial environmental constraints that force RESTful developers into diverging from the “one true REST path” that leads to a more services-based and less structured implementation than perhaps many would like.


MOVING TARGETS

Here’s a few of the problems developers face:

  • HTML (version 4 and lower) and XHTML 1 only support GET and POST in FORMS
  • XHTML 2.0 will support GET, POST, PUT and DELETE  in FORMS but will almost certainly be incompatible with previous versions of HTML/XHTML
  • HTML5 appears to support all necessary HTTP methods, but is being held up by conflicts internal to the W3C WG (Adobe versus the world)
  • XMLHttpRequest support for GET, POST, PUT, DELETE is fairly consistent across browsers
  • XMLHttpRequest is not compatible with cross-domain requests without server-side cooperation 
  • In the interests of security, most web servers disable PUT and DELETE and many administrators are loathe to enable them
  • Storing state entirely on the client would require the transmission of and local storage in inherently insecure ‘containers’ sensitive data, yet not storing state entirely on the client immediately breaks the stateless property required to be considered REST.  
  • Implementing truly RESTful APIs would impact almost every aspect of the environment in which we deploy applications; some changes would be for the better, some not so better.

So developers are sitting between a rock (variability in standards and support) and a hard-place (regulations, risk management, security, web ops concerns). REST is a great concept, and it’s based on established, ubiquitous standards but the problem is that it’s an ideal that does not necessarily take into consideration the environment in which such an architecture would need to be implemented. So it’s no wonder developers have done what developers have always done – worked around the constraints to get the job done. Because you know as well as I do (because you’ve had these conversations, just like I have) that the conversation went something like this:

Developer: We can’t implement a REST API without PUT and DELETE support enabled on the web servers, and we’ll have to store customer information in cookies to maintain a stateless set of operations… oh, and we’re going to increase the size of data because we need self-descriptive messages so the app might run slower on mobile devices.

Info security: No way, we are NOT opening ourselves up like that. Security, you know. Risk. Prison. The CTO wouldn’t look good in blaze orange. Office Nerd

Web ops: What the infosec guy said. Are you kidding? Enable PUT and DELETE? And how large are these messages going to be? Will we need more bandwidth, cause the network guys say we’re already at 60% of our allowed utilization and we can’t have any more because it’s starting to interfere with success of the soft-phone rollout project. 

Business Stakeholder: We need this application and we need it on time.

Marketing: A REST API is tablestakes. We must have one.

Developer: We can’t implement a REST API any other way. REST requires certain architectural characteristics and in the end it will scale better and we’ll have better visibility and -

Business Stakeholder: [eyes glazed over] We need this application and we need it on time, surely you can do something…

Developer: Well, I suppose we could just use GET and POST and then normalize PUT and DELETE as parameters or headers instead.

Web Ops: Excellent! Sounds like you’ve got the problem in hand then, I’m out.

Developer: And we can maintain state in sessions like we always have…

Info security: Excellent! Sounds like you’ve got the problem in hand then, I’m out.

Business Stakeholder: By the way, we’d like to demo the application for user feedback at our next <trade show/user group/shareholder> meeting. Think you can get it done a few weeks early?

Developer: We’d have to work overtime and weekends so -

Business Stakeholder: Excellent! Sounds like you’ve got the problem in hand then, I’m out.

Marketing: By the way, we can still call it REST, right?

And the next thing you know there’s an API available that tries to maintain the spirit of REST while very loosely following the letter of REST. As developers, sometimes we are forced into implementing solutions that break the rules even though we’d prefer to follow them. Cause in the end developers have to serve the needs of the business while working within the constraints of reality – and that means security and regulations and audits and limited bandwidth and other architectural limitations that may force architectural compromises that result in a less than ideal architecture, but a still secure, fast, and efficient application that serves its intended purpose.


GIVE it a REST

The solution is, ultimately, just to not call such APIs REST. Nor RESTful, nor even REST-like. In the same way that we shouldn’t be calling every web-based application “cloud computing” we shouldn’t be calling APIs “REST” when they really aren’t. The argument that what we’re calling today “REST APIs” are really “NO WS-* APIs” is fairly accurate. But to call them simply “web services” would certainly confuse them with their SOAPy counterparts and cause the other side of the fence to rebel just as fiercely.

So until someone comes up with a better name that sticks, we may have to fall back on the tried and true “formerly known as” formula. I propose the “Formerly Unintentionally Counterfactually Known as REST” API.

It still has REST in the name, so marketing should be happy with that, right?


Related blogs & articles:

Follow me on Twitter    View Lori's profile on SlideShare  friendfeed icon_facebook

AddThis Feed Button Bookmark and Share



Feedback

3/3/2010 1:57 AM
Gravatar Well,like Marx said (groucho,of course ) I have this standards ( principles) but if you don't like i have others.
Luis
3/4/2010 1:38 AM
Gravatar Lori,

you might be interested in my Classification of HTTP-based APIs' at nordsc.com/.../...fication_of_http_based_apis.html

I have used the names 'RPC URI-Tunneling', 'HTTP-based Type I' and 'HTTP-based Type II' there to differentiate non-REST APIs from truly RESTful ones.

Jan
Jan Algermissen
3/4/2010 2:02 AM
Gravatar Since URIs ought be treated as opaque, we can't really distinguish verbs and nouns. A URI simply identifies an information resource.

http://iansrobinson.com/i/kick/the-cat

and

iansrobinson.com/3E5F6CF6-2774-11DF-AF20-A59156...

both simply identify information resources.

Trying to identify a domain object and an action being applied to that object in either URI will only lead to problems.

I suggest not overdetermining URIs with domain semantics regarding behavior. The key to implementing rich behaviors is in manipulating an open set of information resources (identified using 'opaque' URIs, even if they look human-readable) using a small set of well-understood (HTTP) verbs with generally agreed safety and idempotency characteristics.

Kind regards

ian
Ian Robinson
3/5/2010 9:15 PM
Gravatar Jan:

Unfortunately your nice tables are just a bunch of boloney and reflect a complete misunderstanding of information system construction. Your conclusion:

>> If you are to any degree concerned with long
>> term maintenance- and evolution cost (which any
>> enterprise IT system owner will need to be),
>> REST is the best solution despite the start-
>> up cost. The start-up cost will amortize in >> the long run.

is just as fallacious as the entire REST theory. As Stu Charlton just concluded, "versioning" of the business logic is not possible in REST, so as a matter of fact "long term maintenance" of a REST-based system is nearly impossible or requires an infinite amount of energy. Versioning is the keystone of distributed systems. This is where CORBA failed, this is where JEE failed. This is where Spring stops and REST sinks. REST requires the assistance of a human user to make versioning work, this is not practical to factor information system that way.
Jean-Jacques Dubray
3/15/2010 12:35 AM
Gravatar Amusingly, I thought I had concluded the opposite to what JJ says....
Stu

Let Me Know What You Think


Please use the form below if you have any comments, questions, or suggestions.

Title:
 
Name:
 
Email: (so we can show your gravatar)
Website:
Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
 
Please add 1 and 6 and type the answer here:

Blog Stats

Posts:979
Comments:1685
Stories:0
Trackbacks:583
  

Image Galleries

  

Application Delivery

  

Cloud Computing

  

Random

  

Security

  

Chat Catcher

82,243 Members in 102 Countries and Growing!

Join DevCentral Today!

About DevCentral

DevCentral has been a successful, thriving community for many years. We have always strived to bring you the best technical documentation, discussion forums, blogs, media and much more that we can.

So dive in, get familiar with DevCentral. We hope you like it, we hope it makes your job easier, and lets you get that much more power out of the community. To learn more, make sure to check out the Getting Started section. And if you have any problems, or think something could be easier to use, drop us a line to let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback       or