Java Reference
In-Depth Information
<link rel=
"self"
href=
"http://example.com/..."
//>
jects in our ecommerce system where on the network the client can interact with that particu-
lar resource. The
rel
attribute tells the client what relationship the link has with the resource
the URI points to (contained within the
href
attribute). The
self
value just means it is
pointing to itself. While not that interesting on its own,
link
becomes very useful when we
aggregate or compose information into one larger XML document.
<link
The details
So, with the common elements described, let's start diving into the details by first looking at
our
Customer
representation format:
<customer
<customer id=
"117"
>
<link
<link rel=
"self"
href=
"http://example.com/customers/117"
//>
<first-name>
<first-name>
Bill
</first-name>
</first-name>
<last-name>
<last-name>
Burke
</last-name>
</last-name>
<street>
<street>
555 Beacon St.
<street>
<street>
<city>
<city>
Boston
</city>
</city>
<state>
<state>
MA
</state>
</state>
<zip>
<zip>
02115
</zip>
</zip>
</customer>
pand its attributes as XML elements.
Product
looks much the same in terms of simplicity:
<product
<product id=
"543"
>
<link
<link rel=
"self"
href=
"http://example.com/products/543"
//>
<name>
<name>
iPhone
</name>
</name>
<cost>
<cost>
$199.99
</cost>
</cost>
</product>
In a real system, we would, of course, have a lot more attributes for
Customer
and
Product
,
but let's keep our example simple so that it's easier to illustrate these RESTful concepts:
<order
<order id=
"233"
>
<link
<link rel=
"self"
href=
"http://example.com/orders/233"
//>
<total>
<total>
$199.02
</total>
</total>
<date>
<date>
December 22, 2008 06:56
</date>
</date>
<customer
<customer id=
"117"
>
<link
<link rel=
"self"
href=
"http://example.com/customers/117"
//>
<first-name>
<first-name>
Bill
</first-name>
</first-name>
<last-name>
<last-name>
Burke
</last-name>
</last-name>
<street>
<street>
555 Beacon St.
<street>
<street>
<city>
<city>
Boston
</city>
</city>