Java Reference
In-Depth Information
Developing REST-based web services
JAX-RS
(JSR-311) is a new JCP specification that provides a Java API for RESTful
web services in the HTTP protocol.
In their simplest form, RESTful web services are networked applications that manip-
ulate the state of system resources. In this context, resource manipulation means re-
source creation, retrieval, update, and deletion (CRUD). However, RESTful web ser-
vices are not limited to just these four basic data manipulation concepts. On the con-
trary, RESTful web services can execute logic at the server level, but, remember that
every result must be a resource representation of the domain.
The main difference with SOAP web services is that REST asks developers to use
HTTP methods explicitly and in a way that's consistent with the protocol definition.
This basic REST design principle establishes a
one-to-one
mapping between CRUD
operations and HTTP methods.
Therefore, with the delineated roles for resources and representations, we can now
map our CRUD actions to the HTTP methods
POST
,
GET
,
PUT
, and
DELETE
as fol-
lows:
Action
HTTP protocol equivalent
RETRIEVE
GET
CREATE
POST
UPDATE
PUT
DELETE
DELETE