Chapter 6. Creating Web Service Applications with JAX-WS

Introduction

The SAAJ API, introduced in Chapter 5, offers a powerful, flexible way to work with web services at a low level. The Java API for XML Web Services (JAX-WS) is a high-level API for consuming and providing web services. This chapter introduces JAX-WS and shows you how to use it for a wide variety of practical tasks.

JAX-WS in Relation to Other APIs

JAX-WS replaces the older JAX-RPC API. Unlike SAAJ, JAX-WS doesn’t require you to know very much about XML or WSDL. The entire XML layer is hidden from developers, who can instead just work with objects generated by web services tools that come with Java SE 6 and EE 5. These objects encapsulate all of the work of creating SOAP messages, invoking the service, and parsing responses, hiding significant complexity from developers. This can be convenient, and can make client maintenance much easier.

JAX-WS actually is built on top of SAAJ, using it under the hood to do its parsing and communication work. As you know, a web service as represented in a WSDL will define XML types for each of the message parts used in service requests and responses. In order to create object representations of these types, you need a binding language to convert (marshal) from Java to XML and back again. In the older API, this was done directly within JAX-RPC, which defined its own conversion mechanism. However, this was later deemed to complicate the specification, and Java to XML conversion came ...

Get Java SOA Cookbook 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.