Name
SOAPHeader
Synopsis
public interface SOAPHeader extends SOAPElement { // Public Instance Methods public abstract SOAPHeaderElement addHeaderElement Namename
) throws SOAPException; public abstract Iterator examineHeaderElements(Stringactor
); public abstract Iterator extractHeaderElements(Stringactor
); }
SOAPHeader
is a subinterface of
SOAPElement
that acts as a container for SOAP
message headers. A single SOAPHeader
element is
always found as the first element of the
SOAPEnvelope
within a
SOAPMessage
returned by the default
MessageFactory
provided by the SAAJ reference
implementation. However, since the use of headers is optional, if it
is not required, it may be removed by calling its
detachNode( )
method:
SOAPMessage msg = factory.createMessage; SOAPPart part = msg.getSOAPPart; SOAPHeader header = part.getEnvelope.getHeader; header.detachNode;
A SOAPHeader
may contain any number of SOAP
headers, which are represented by
SOAPHeaderElement
s. The most direct way to add a
header is to use the addHeaderElement( )
method,
which requires a Name
object as its argument.
Other elements may be nested within the
SOAPHeaderElement
as required. The following code
adds the header code BookHeader
to a SOAP message:
SOAPHeader header = part.getEnvelope.getHeader; SOAPHeaderElement e = header.addHeaderElement( factory.createName("BookHeader", "book", "urn:BookService"));
Alternatively, the addChildElement( )
methods that
SOAPHeader
inherits from
SOAPElement
can be used to achieve the same result. ...
Get Java Web Services in a Nutshell 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.