You can enable an existing 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
WSDL file, but the message definition is not referenced by a portType 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.
You
cannot manipulate protected SOAP headers. A SOAP header that is declared protected
by its owning component, for example, Web Services Security, is not accessible
to client applications. An exception occurs if you try to manipulate protected
SOAP headers.
About this task
The client application sets properties on the Stub or Call object
to send and receive implicit SOAP headers. You can modify the client code
as follows:
Procedure
- Create a java.util.HashMap.
- Add an entry to the HashMap 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.
- Set the HashMap 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.
- Issue the remote method calls using the Stub or Call object.
The headers within the HashMap are sent in the outgoing message.
A
JAXRPCException can
occur if any of the following are true:
- The HashMap contains a key that is not a QName or if the HashMap contains
a value that is not a String or a SOAPElement.
- The HashMap contains a key that represents a SOAP header that is declared
protected by the owning component.
Results
You have a Web service client that is configured to send implicit
SOAP headers.