Wednesday, July 21, 2010

New JAX-WS Lightweight API Allows Fast Access and Manipulation of SOAP Headers

Background:
SOAP Headers are typically used to pass additional context data to and from SOAP nodes.
JAX-WS provides a SAAJ API rendering of the message that can be queried and manipulated by JAX-WS application handlers.

Problem:
The SAAJ rendering of a message is heavyweight.
The JAX-WS runtime is optimized to stream inbound and outbound messages. Transforming the message into an intermediate SAAJ rendering is inefficient and increases the memory footprint.

Solution:
IBM has defined an alternative lightweight API that can be used to access and manipulate SOAP headers from within a JAX-WS handler.

This API is available in version 7.0.0.5 of the WebSphere Application Server:
PK96816

This API is available in version 6.1.0.27 of the Feature Pack for Web Services:
PK84170

We've documented the ability to set headers on outbound requests here:
instructions for setting SOAP Headers and retrieve SOAP headers here: instructions for accessing SOAP Headers

Example Usage
Here is an example usage.

Interested Parties:
This solution is applicable if your JAX-WS Web service uses large messages and requires high performance and/or low memory footprint.

This solution is also applicable for customers migrating existing JAX-RPC Web services to JAX-WS.