Java Reference
In-Depth Information
ample, browsers need HTML, JavaScript needs JSON (JavaScript Object Notation), and
a Java application may need XML.
Communicate statelessly
Stateless applications are easier to scale.
Hypermedia As The Engine Of Application State (HATEOAS)
Let your data formats drive state transitions in your applications.
For a PhD thesis, Fielding's paper is actually very readable and, thankfully, not very long. It,
along with Leonard Richardson and Sam Ruby's book RESTful Web APIs (O'Reilly), is an
excellent reference for understanding REST. I will give a much briefer introduction to REST
and the Internet protocol it uses (HTTP) within this chapter.
REST and the Rebirth of HTTP
REST isn't protocol-specific, but when people talk about REST, they usually mean REST
over HTTP. Learning about REST was as much of a rediscovery and reappreciation of the
HTTP protocol for me as learning a new style of distributed application development.
Browser-based web applications see only a tiny fraction of the features of HTTP. Non-
RESTful technologies like SOAP and WS-* use HTTP strictly as a transport protocol and
thus use a very small subset of its capabilities. Many would say that SOAP and WS-* use
HTTP solely to tunnel through firewalls. HTTP is actually a very rich application protocol
that provides a multitude of interesting and useful capabilities for application developers.
You will need a good understanding of HTTP in order to write RESTful web services.
HTTP is a synchronous request/response-based application network protocol used for distrib-
uted, collaborative, document-based systems. It is the primary protocol used on the Web, in
particular by browsers such as Firefox, MS Internet Explorer, Safari, and Netscape. The pro-
tocol is very simple: the client sends a request message made up of the HTTP method being
invoked, the location of the resource you are interested in invoking, a variable set of headers,
and an optional message body that can basically be anything you want, including HTML,
plain text, XML, JSON, and even binary data. Here's an example:
GET / resteasy HTTP / 1.1
Host: jboss . org
User - Agent: Mozilla / 5.0
Accept: text / html , application / xhtml + xml , application / xml ; q = 0.9 ,*/*; q = 0.8
Accept - Language:
en - us , en ; q = 0.5
Accept - Encoding:
gzip , deflate
Your browser would send this request if you wanted to look at http://jboss.org/resteasy . GET
is the method we are invoking on the server. /resteasy is the object we are interested in.
Search WWH ::




Custom Search