The concept of RESTful web services originated in Dr. Roy Fielding's dissertation titled
“Architectural Styles and the Design of Network-based Software Architectures.” In his pa-
per, Dr. Fielding examined how the architecture of the web emerged and formulated a set
of architectural principles, which he called representational state transfer (REST). These
principles derive from his work on the HTTP 1.0 and 1.1 specifications, of which he was
one of the principal authors. Unlike SOAP, REST isn't a standard.
RESTful web services fully use the HTTP protocol and URIs (uniform resource identi-
fiers), which aren't fully exploited by SOAP. SOAP primarily uses HTTP as a transport
mechanism because it's ubiquitous and can easily drill through firewalls. RESTful web
services map the basic HTTP operations— DELETE , GET , HEAD , OPTIONS , POST , and
PUT —to URIs. The HTTP operations thus provide the basic CRUD functionality. The pay-
load for these messages can be anything—XML, graphics, text, and so on. Unlike SOAP,
where the contents of the SOAP message determine the operation, a unique URL is used
to call the RESTful web service. Parameters are passed in using a query. All of these were
unused or underutilized with SOAP.
On the Java EE platform, JAX-RS defines the APIs for building a RESTful web service.
JAX-RS has no dependence on EJBs and can be used to expose POJOs as RESTful web
services. But as you've seen several times already, EJBs offer a number of advantages in-
cluding integration with transactions. Exposing EJBs as REST is conceptually no different
than exposing the beans as SOAP. Let's review the basics of REST.
8.3.1. Basics of REST
SOAP-based web services use HTTP as a transport mechanism. An HTTP POST or GET
invocation is performed and a block of XML is uploaded to the server and ultimately pro-
cessed. The request URI identifies the service, but it's the actual contents of the XML ex-
changed that determines what action is performed and what is returned to the client. Look-
ing at the request URI, you can't necessarily tell what the operation does or whether there
has been a state change on the server. REST, however, fully uses HTTP.
Let's consider the case of an HTTP form submission from the browser using HTTP GET .
You fill out the form and then click Submit. In the browser URL bar you see something
like the following: