40 CHAPTER 1: Introducing Java Web Development
Note JSON Processing is defined as the Java API for JSON Processing in JSR 353; see Table 1-3.
Two Java APIs facilitate web services:
JAX-WS: This is based on the Simple Object Access Protocol (SOAP),^29 which
is an XML-based protocol that allows web services and clients to communicate,
even if the client and the web service are written in different languages.
JAX-RS: This uses Representational State Transfer (REST), which is a network
architecture that uses the Web’s traditional request-response mechanisms such
as GET and POST requests.
Simple Object Access Protocol
The Simple Object Access Protocol (SOAP) is a platform-independent protocol that uses XML to
interact with web services, typically over HTTP. Each request and response is packaged in a SOAP
message, which is XML markup containing the information that a web service requires to process
the message. A SOAP web service works as follows:
- When a method of a SOAP web service is invoked, the request is packaged
in a SOAP message enclosed in a SOAP envelope and sent to the server on
which the web service resides. - When the SOAP )web service receives this message, it parses the XML
representing the message and then processes the message’s contents. - Then, the web service, after processing the request, sends the response to
the client in another SOAP message. - The client parses the response.
Representational State Transfer
The term representational state transfer (REST) was introduced and defined in 2000 by Roy Fielding
in his doctoral dissertation^30 at UC Irvine. REST refers to an architectural style for implementing
web services called RESTful web services. Each method in a RESTful web service is identified by a
unique URL.
Note RESTful web services are defined as JSR 339, as shown in Table 1-3.
(^29) http://www.w3.org/TR/soap/
(^30) http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm