Java Reference
In-Depth Information
The client would do a GET /orders/333 and get the XML document representing the order.
If the document contains the cancel link, the client is allowed to change the order status to
“cancelled” by doing an empty POST or PUT to the URI referenced in the link. If the docu-
ment doesn't contain the link, the client knows that this operation is not possible. This allows
the web service to control how the client is able to interact with it in real time.
W3C standardized relationships
An interesting thing that is happening in the REST community is an effort to define, register,
and standardize a common set of link relationship names and their associated behaviors. [ 11 ]
Some examples are given in Table 10-1 .
Table 10-1. W3C standard relationship names
Relationship Description
A URI that refers to the immediately preceding document in a series of documents.
A URI that refers to the immediately following document in a series of documents.
A URI that can be retrieved, updated, and deleted.
A URI where payment is accepted. It is meant as a general way to facilitate acts of payment.
This is not an exhaustive list, but hopefully you get the general idea where this registry is
headed. Registered relationships can go a long way to help make data formats even more
self-describing and intuitive to work with.
Link Headers Versus Atom Links
While Atom links have become very popular for publishing links in RESTful systems, there
is an alternative. Instead of embedding a link directly in your document, you can instead use
Link response headers. [ 12 ] This is best explained with an example.
Consider the order cancellation example described in the previous section. An Atom link is
used to specify whether or not the cancelling of an order is allowed and which URL to use to
do a POST that will cancel the order. Instead of using an Atom link embedded within the or-
der XML document, let's use a Link header. So, if a user submits GET /orders/333 , he will
get back the following HTTP response:
Search WWH ::

Custom Search