+

Search Tips   |   Advanced Search

Sending implicit SOAP headers with JAX-RPC


We can enable an existing JAX-RPC Web services client to send values in implicit SOAP headers. By modifying the client code to send implicit SOAP headers, we can send specific information within an outgoing Web service request.

To complete this task, we need a Web services client that we can enable to send implicit SOAP headers. An implicit SOAP header is a SOAP header that fits one of the following descriptions:

Handlers and service endpoints can manipulate implicit or explicit SOAP headers using the SOAP with Attachments API for Java (SAAJ) data model.

We cannot manipulate protected SOAP headers. A SOAP header that is declared protected by its owning component, for example, WS-Security, is not accessible to client applications. An exception occurs if we try to manipulate protected SOAP headers.

The client application sets properties on the Stub or Call object to send and receive implicit SOAP headers.

 

  1. Create a java.util.HashMap object.

  2. Add an entry to the HashMap object for each implicit SOAP header that the client wants to send. The HashMap entry key is the QName of the SOAP header. The HashMap entry value is either an SAAJ SOAPElement object or a String that contains the XML text of the entire SOAP header element.

  3. Set the HashMap object as a property on the Stub or Call object.

    The property name is com.ibm.websphere.webservices.Constants.REQUEST_SOAP_HEADERS. The value of the property is the HashMap.

  4. Issue the remote method calls using the Stub or Call object.

    The headers within the HashMap object are sent in the outgoing message.A JAXRPCException error can occur if any of the following are true:

    • The HashMap object contains a key not a QName object or if the HashMap object contains a value not a String or a SOAPElement object.

    • The HashMap object contains a key that represents a SOAP header that is declared protected by the owning component.

 

Results

we have a JAX-RPC Web services client configured to send implicit SOAP headers.


SOAP with Attachments API for Java interface

 

Related tasks


Receiving implicit SOAP headers with JAX-RPC
Implementing extensions to JAX-RPC Web services clients

 

Related


Example: Using JAX-RPC properties to send and receive SOAP headers