Java Reference
In-Depth Information
Java API for RESTful Web Services
The Java API for RESTful Web Services 2.0 Specification was developed under
JSR 339. This section just gives you an overview of improvements in the API. The
complete document specification (for more information) can be downloaded from ht-
tp:// .
When to use Web Services
A Web Service is a software system based on open standards (such as HTTP, XML,
and URI) and designed to allow exchanges between applications across the network.
By using these open standards, it has everything required to be the most suitable
solution for integrating heterogeneous systems. However, as we saw when we were
talking about JMS, the choice of an integration solution should be made after a series
of questions: Is the network connection good? Are the processes transactional? Is the
amount of data to be processed huge? Must processing be synchronous? and so on.
If after investigation, your choice is Web Services, you must now select the type of
web service to implement : the SOAP Web Services based on SOAP ( Simple Object
Access Protocol ) and XML, or RESTful Web Services that are focused on resource
sharing and thus their functioning is modeled on the Web. In this topic, we will only
discuss RESTful Web Services.
JAX-RS in action
RESTful Web Services are a variant of Web Services in which any concepts that can
be addressed (functionality or data) are considered as resources and therefore can
be accessed through Uniform Resource Identifiers ( URI s). Once located, the rep-
resentation or state of the resource is transferred in the form of an XML or a JSON
document. In the case of our online preregistration application, the resources may be
the list of selected students and the representation will be in a JSON document.
JAX-RS is the Java API to implement RESTful Web Services. The following code
demonstrates how to write a REST service that returns a list of all students who were
Search WWH ::

Custom Search