Java Reference
In-Depth Information
8.1.4. Java EE web service APIs
In this chapter we'll delve into the nuts and bolts of exposing EJBs via SOAP and RESTful
web services. When looking over the Java EE specification or browsing articles online,
you'll be confronted with an alphabet soup of acronyms. JAX-WS (JSR 224) and JAX-
RS (JSR 399) in Java EE 7 define the standard APIs for creating SOAP and RESTful web
services, respectively. These are specifications for which there are different implementa-
tions. Because Java EE 7 mandates JAX-WS and JAX-RS, you won't need to worry about
picking an implementation unless you choose to deviate from the one provided by your
container. Some implementations available are Metro ( ) , which is in-
cluded with GlassFish, and Apache Axis 2 ( ).
As you peruse the Java EE documentation, you may come across JAX-RPC. JAX-RPC was
the forerunner to JAX-WS in J2EE 1.4. JAX-RPC is a legacy technology and should be
replaced whenever possible. JAX-WS is much easier to use with many more features. The
complexity of JAX-RPC gave web services in Java a bad reputation.
In addition to JAX-WS and JAX-RS, JAXB will also be covered. JAXB is the Java archi-
tecture for XML binding. As its name implies, it's responsible for converting a Java object
graph into XML and back again. JAXB can be used to generate your data model from an
XML schema, which can then be persisted to XML, or you can annotate your code; the
latter approach is what we'll take in this chapter. Comprehensive coverage of JAXB is bey-
ond the scope of this chapter—we'll cover enough to give you an introduction.
New to Java EE 7 is JSON support (JSR 353). JSON stands for JavaScript object notation
and it's a compact encoding of data. You'll use JSON when we cover the RESTful web ser-
vices. RESTful web services often use JSON as the response. This is useful if you're build-
ing a website that's heavily interactive with lots of JavaScript code. XML is very verbose,
consumes bandwidth, and also consumes resources on both the client and server. When us-
ing an interactive web application that uses AJAX, JSON is definitely the approach to take.
8.1.5. Web services and JSF
You might have started reading this chapter in the hope of mastering web services so that
you can construct a user interface that uses AJAX and therefore web services. JSF has its
own built-in support for AJAX and handles marshaling information between the client and
Search WWH ::

Custom Search