Java Reference
In-Depth Information
One of the uses of hypermedia and hyperlinks is composing complex sets of information
from disparate sources. The information could be within a company intranet or dispersed
across the Internet. Hyperlinks allow us to reference and aggregate additional data without
bloating our responses. The ecommerce order in Addressability is an example of this:
< order id = "111" >
< customer > http: //customers.myintranet.com/customers/32133 </ customer >
< order - entries >
< order - entry >
< quantity > 5 </ quantity >
< product > http: //products.myintranet.com/products/111 </ product >
...
In that example, links embedded within the document allowed us to bring in additional in-
formation as needed. Aggregation isn't the full concept of HATEOAS, though. The more in-
teresting part of HATEOAS is the “engine.”
The engine of application state
If you're on Amazon.com buying a book, you follow a series of links and fill out one or two
forms before your credit card is charged. You transition through the ordering process by ex-
amining and interacting with the responses returned by each link you follow and each form
you submit. The server guides you through the order process by embedding where you
should go next within the HTML data it provides your browser.
This is very different from the way traditional distributed applications work. Older applica-
tions usually have a list of precanned services they know exist, and they interact with a cent-
ral directory server to locate these services on the network. HATEOAS is a bit different be-
cause with each request returned from a server it tells you what new interactions you can do
next, as well as where to go to transition the state of your applications.
For example, let's say we wanted to get a list of products available on a web store. We do an
HTTP GET on http://example.com/webstore/products and receive back:
< products >
< product id = "123" >
< name > headphones </ name >
< price > $16 . 99 </ price >
</ product >
< product id = "124" >
< name > USB Cable </ name >
< price > $5 . 99 </ price >
</ product >
...
</ products >
Search WWH ::




Custom Search