samedi, juin 21, 2008

SpringOne08: RESTFUL Web Services

Late publication, didn't have the time back then ;)

A general presentation of REST:
- Everything is a resource (which has a value to the user). These are expressed by URIs and nouns
- Uniform interface (GET, HEAD, POST, PUT, DELETE, OPTIONS, and optionally TRACE)

GET:
safe operation (can be repeated) that retrieves a representation of the Resource.
GET is Cacheable (Servers return ETag or LastModified)

HEAD: identical to GET without response body, only headers.

POST: creates a new Resource (Typically as a child to another Resource)
POST /hotels/1/bookings/ for example returns a location like: /hotels/1/bookings/50/

PUT: updates a resource or creates a resource when the destination URI is known.
As opposed to POST this can be repeated affecting the same resource.

DELETE: IdemPotent, if an item is not there, it doesn't fail.

OPTIONS:
retrieves allowed HTTP methods on a resource.


Resource reprensentations => multiple representations (html, image, json... etc)

Stateless conversation:
no HTTP Session! State is maintained through transitions between links. As a result, the result is very scalable and enforces loose coupling.

Hypermedia: fancy word for links ;), XLink is a spec for that and allows seamless evolution.