Java Reference
In-Depth Information
Chapter 4. Getting Started
Introduction
JAX-WS, or Java API for XML Web Services, offers a set of three basic choices for connect-
ing to web services: Dynamic Invocation, Proxy, and SAAJ. The first two hide the complex-
ity of dealing with the XML plumbing under the hood. The third gives you full access to the
SOAP envelope in an XML view, as well as a few different ways to control the invocation of
your SOAP requests.
Given this flexibility, it is easy to use JAX-WS clients to invoke web services. But there is
an initial hump to get over in sorting out the differences in the three APIs and determining
when to use each. There are a number of standard variations on the basic request and response
that can get pretty tricky. Once you need to decorate a request (see Intercepting the Request
to Perform Protocol-Specific Work ) , or want to add MIME attachments or custom headers to
your SOAP message, or invoke your client asynchronously, there's some work to be done.
One initially confusing thing about web services is the way things are named. For example,
you might think that the Service class is used to create a web service implementation. But it
isn't; instead, it represents a Service Endpoint Interface on the client side, acting as a proxy
for the service endpoint you actually want to invoke. Another potentially confusing area is the
great number of classes and annotations that you typically won't be using directly, depending
on your approach. If you're just browsing the JavaDocs in the Java EE 5 API, you might not
know if you're supposed to write a @WebService annotation on the same class as a Provider
annotation (you're not), or whether Provider implementations go on the client if Services do
(they don't). But that's what this chapter is all about.
This chapter is a “convenience chapter” of sorts. It is about getting set up with some tools and
getting a sense of the publicly available web service landscape. In the first chapter, we looked
at general SOA concepts and terms; this chapter zeroes in on web service-specific concepts,
such as SOAP and WSDL. We get together some tools we need to deploy and consume ser-
vices and make your first Hello World web service, and we close with a brief look at monitor-
ing tools to aid in debugging.
If you are interested in reading the specifications that support modern Java web services de-
velopment, they include:
JSR 181
JSR 181
Web Services Metadata for the Java Platform. Provides many of the annotations used to
sew together and deploy web services.
Search WWH ::




Custom Search