Over a million developers have joined DZone.

Solomon Duskis on REST - Presented in HTTP

DZone's Guide to

Solomon Duskis on REST - Presented in HTTP

· Integration Zone ·
Free Resource

WSO2 is the only open source vendor to be named a leader in The Forrester Wave™: API Management Solutions, Q4 2018 Report. Download the report now or try out our product for free.

I'm preparing for an internal REST presentation. I'm going to use this blog as my presentation platform. Power Points can be pretty, but I think that it's ideal to have a presentation about REST in an HTML/HTTP/URL environment.

Here's a rough outline of the presentation:

  1. A brief history of the web, from a data-oriented perspective
  2. REST by Roy (gbiv.com)
  3. Java RESTful Services - JAX-RS


A brief history of the web, from a data-oriented perspective

W3C standards: URI, HTTP, HTML - the foundations of the web. The first spec for these three protocols proposed in 1994.

  • URI - Anything important (a Resource) has an identifier.
  • HTTP - Use a standard communication protocol. GET/POST verbs, URLs, headers (including caching)
  • HTML - A standard UI Resource language, but also a language that expresses relationships with other Resources (a, src, form...).

Of course the web has Resources that are images, PDFs, JavaScript, XML, JSon and a whole lot more.

There has been a progression of the way people and computers interact on the Web on top of those W3C standards.

  • The Web - Where were you the last decade and a half? - data interactions using HTML links, images, forms
  • Web 2.0 - AJAX as an optimization. Data oriented communication (AJAX) to provide desktop-like functionality, plus a whole bunch of other goodies outlined by Tim O'Rielly and of course the rounded edges :). Mashups and serendipity.
  • Web 3.0 - (huh? is this for real?) The Semantic Web, hyper-connected data - connected computers; and uber-social media - connecting hyper people. Engineered Serendipity.


REST by Roy (gbiv.com)

So what does this have to do with REST? REST stands for Representational State Transfer. REST is the architectural principles behind the distributed programming principles of the web.

Roy Fielding co-wrote the original HTML/HTTP/URL W3C specs and still heavily involved with those standards to fill in some details that came up with the relatively new addition of data-oriented services (Don't use OPTION, it doesn't support Caching; the behavior of PUT with complex caching). He wrote the book (or rather the dissertation) on REST. He's the co-wrote Apache httpd and has since been on the Apache Software Chair commitee. He's been involved with Apache Sling which is a product centered around JCR.

REST comes down to the following principles (quoted from Chapter 5: Deriving REST):

  1. Client Server - the separation allows the components to evolve independently, thus supporting the Internet-scale requirement of multiple organizational domains.

  2. Stateless Communication - each request from client to server must contain all of the information necessary to understand the request. Any instance of "the server" should be able to process an incoming request.

  3. Cache - Cache constraints require that the data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable

  4. Uniform Interface - REST is defined by four interface constraints: identification of resources; manipulation of resources through representations; self-descriptive messages; and, hypermedia as the engine of application state

  5. Layered System - By restricting knowledge of the system to a single layer, we place a bound on the overall system complexity and promote substrate independence

  6. Code-On-Demand - REST allows client functionality to be extended by downloading and executing code in the form of applets or scripts

If you want, you can read more about it in a previous blog entry of mine - "What's REST Anyway".

A quick word about Statelessness: This constraint is a bit murky. It's not that the server can't store "resource state". This constraint is broken when the client is tied to a specific instance of the server (similar to what happens with jsessionid)

A quick word about Uniform Interface:

  1. identification of resources - URLs, URNs - something globally unique and well understood

  2. manipulation of resources through representations - HTML, form fields, JSon, XML, PDF... You're not manipulating the resource itself. Content Negotiation

  3. self-descriptive messages - A person or a computer should be able to read the represtation. HTTP headers describe quite a bit about requests and responses, standardized verbs (GET/POST/PUT/DELETE/OPTIONS/HEAD). HTML forms are sort of like WSDL - defining future communication.

  4. hypermedia as the engine of application state (HATEOAS) - the most controversial and least understood REST constraint. I wrote about it, in fact my blog is full of it. BTW, some people pronounce this constraint Hate Yo' A$$.

On October 2008 Roy Fielding got really frustrated that so-called REST APIs don't implement this constraint and he explained the HATEOAS constraint (now renamed "The hypertext constraint") further. I read Roy's post quite a few times, but still didn't fully GET it. (quick word on single point of entry, workspaces and Serendipity)... I asked the experts on the rest-discuss Yahoo group about how and why they implement the hypertext constraint and got some astounding answers.

Q & A on REST - (if we have time)



Java RESTful Services - JAX-RS and RESTEasy

JAX-RS (JSR 311) - Java API for XML and RESTful Services. It's a standard created by the java community's REST experts. It's a collection of annotations, interfaces and some guidelines on how to map data-oriented services.


  1. Bill Burke's Putting Java to REST (September 2008 - DZone)
  2. An overview of JAX-RS 1.0 Features
  3. James Strachan's JAX-RS as the one Java web framework to rule them all? (January 2009 - blog)

A quick Web + JAX-RS demo. with XML/JSon/HTML/Form representations (and a dash of Spring and Jetty). Let's see @Path and other JAX-RS annotations. JUnit Test with Embedded Web Server

Possibly another demo - Flickr client and RESTEasy client goodies - embedded Web Browser with MozSwing, with Resteasy's built in client-side cache.

What do you think you could do with an embedded server and an embedded browser?

Q & A?

IAM is now more than a security project. It’s an enabler for an integration agile enterprise. If you’re currently evaluating an identity solution or exploring IAM, join this webinar.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}