Sending implicit SOAP headers with JAX-WS

You can enable an existing Java™ API for XML-Based Web Services (JAX-WS) Web services client to send values in implicit SOAP headers. By modifying your client code to send implicit SOAP headers, you can send specific information within an outgoing Web service request.

Before you begin

To complete this task, you need a Web services client that you can enable to send implicit SOAP headers.

An implicit SOAP header is a SOAP header that fits one of the following descriptions:
  • A message part that is declared as a SOAP header in the binding in the Web Services Description Language (WSDL) file, but the message definition is not referenced by a portType element within a WSDL file.
  • An element that is not contained in the WSDL file.

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

Using JAX-WS, there is no restriction on types of headers that you can manipulate.

About this task

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

Procedure

  1. Create a java.util.HashMap<QName, List<String>> 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 a List<String> object, and each String is the XML text of the entire SOAP header element. By using List<String> object, you can add multiple SOAP header elements that each have the same QName object.
  3. Set the HashMap object as a property on the request context of the Dispatch or Proxy object. The property name is com.ibm.wsspi.websvcs.Constants.JAXWS_OUTBOUND_SOAP_HEADERS. The value of the property is the HashMap.
  4. Issue the remote method calls using the Dispatch or Proxy object. The headers within the HashMap object are sent in the outgoing message.
    A WebServiceException error can occur if any of the following are true:
    • The HashMap object contains a key that is not a QName object or if the HashMap object contains a value that is not a List<String> object.
    • The String representing an SOAP header is not a compliant XML message.
    • The HashMap contains a key that represents a SOAP header that is declared protected by the owning component.

Results

You have a JAX-WS Web services client that is configured to send implicit SOAP headers.




In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 5:30:17 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=compass&product=was-nd-iseries&topic=twbs_reqsoapheadjaxws
File name: twbs_reqsoapheadjaxws.html