A RESTful Service as a @WebServiceProvider
JAX-WS includes APIs for RESTful and SOAP-based web services, although JAX-WS seems to be used mostly for the latter. The reference implementation is Metro, which is part of the GlassFish project. Although JAX-WS technically belongs to enterprise rather than core Java, the core Java JDK (1.6 or greater) includes enough of the Metro distribution to compile and publish RESTful and SOAP-based services. JAX-RS and Restlet are state-of-the-art, high-level APIs for developing RESTful services; by contrast, the JAX-WS API for RESTful services is low-level. Nonetheless, JAX-WS support for RESTful services deserves a look, and the JAX-WS API for SOAP-based services will be the centerpiece in Chapter 4 and Chapter 5.
The JAX-WS stack reflects the view that SOAP-based services over HTTP are refinements of RESTful services. The JAX-WS API has two
main annotations. A POJO class annotated as a @WebService
delivers a SOAP-based service, whereas
a POJO class annotated as a @WebServiceProvider
usually delivers a RESTful one; however, a class annotated as
a @WebServiceProvider
can deliver
a SOAP-based service as well. Yet another revision of the adages RESTful service, adages3, introduces the JAX-WS API for
RESTful services.
In the revised adages3 service, the Adage
and Adages
classes are mostly unchanged from the adages2 version. One small change
is that the package name goes from adages2
to adages3
; another change is that the Adage
list is returned as array, ...
Get Java Web Services: Up and Running, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.