Java Reference
In-Depth Information
Chapter 7. Providing SOAP-Based Web Services
Introduction
Web services have been available in Java for years, but working with them as a developer has
been a complicated process, involving a great number of brittle steps. With the advent of Java
EE 5, much of this complexity has been reduced. Deployment descriptors have given way to
annotations, and much of the boilerplate work is generated for you.
Despite this good news, doing web services in the real world remains very tricky. The actual
complexity of web services is still very real; the fact that we are shielded from some of the
grunt work does not change how the plumbing works. Writing maintainable, flexible code that
prevents vendor lock-in as much as possible is a challenge on any project. The added flexib-
ility in Java EE 5 gives us more options; which is terrific, but it also presents us with a new
array of configuration and implementation choices that can be daunting to the novice. So we
have a lot of work ahead of us to figure out how all of the pieces go together.
If you have worked with web services in previous versions of Java, you can build on your
background knowledge, but the new APIs represent a fundamental change in how we as web
services developers approach our work. Here are some of the ways in which the world has
changed with Java EE 5:
▪ No need to write webservices.xmldeployment descriptor. This file used to be mandatory.
Now, instead of a single web services-related descriptor file, annotations handle all of that
work. Of course, you now have to learn to write all those annotations.
▪ No JAX-RPC file for mapping Java to WSDL needs to be packaged with your deploy-
ment.
▪ No need for an interface. JAX-RPC required developers to have their service implementa-
tion implement an interface that extends Remote. Now, a single class annotated with @We-
bService is all that is required.
▪ No JNDI lookups. Clients such as servlets or EJBs no longer need to use <service-ref>
elements in their deployment descriptors (web.xmlor ejb-jar.xml) to look up services in
order to invoke them. Using the new JAX-WS generated clients with a @WebServiceRef
or @WebServiceClient annotation will do this work for you.
▪ Using Endpoint in a regular Java SE 6 JVM is a very simple way to get started with web
services for testing purposes. This lowers the barrier to entry. And now it's simplified even
Search WWH ::




Custom Search