Class JAXBHeader

java.lang.Object
com.sun.xml.ws.message.AbstractHeaderImpl
com.sun.xml.ws.message.jaxb.JAXBHeader
All Implemented Interfaces:
Header

public final class JAXBHeader extends AbstractHeaderImpl
Header whose physical data representation is a JAXB bean.
Author:
Kohsuke Kawaguchi
  • Constructor Details

  • Method Details

    • getNamespaceURI

      @NotNull public String getNamespaceURI()
      Description copied from interface: Header
      Gets the namespace URI of this header element.
      Returns:
      this string must be interned.
    • getLocalPart

      @NotNull public String getLocalPart()
      Description copied from interface: Header
      Gets the local name of this header element.
      Returns:
      this string must be interned.
    • getAttribute

      public String getAttribute(String nsUri, String localName)
      Description copied from interface: Header
      Gets the attribute value on the header element.
      Parameters:
      nsUri - The namespace URI of the attribute. Can be empty.
      localName - The local name of the attribute.
      Returns:
      if the attribute is found, return the whitespace normalized value. (meaning no leading/trailing space, no consequtive whitespaces in-between.) Otherwise null. Note that the XML parsers are responsible for whitespace-normalizing attributes, so Header implementation doesn't have to do anything.
    • readHeader

      public XMLStreamReader readHeader() throws XMLStreamException
      Description copied from interface: Header
      Reads the header as a XMLStreamReader.

      The returned parser points at the start element of this header. (IOW, XMLStreamReader.getEventType() would return XMLStreamConstants.START_ELEMENT.

      Performance Expectation

      For some Header implementations, this operation is a non-trivial operation. Therefore, use of this method is discouraged unless the caller is interested in reading the whole header.

      Similarly, if the caller wants to use this method only to do the API conversion (such as simply firing SAX events from XMLStreamReader), then the JAX-WS team requests that you talk to us.

      Messages that come from tranport usually provides a reasonably efficient implementation of this method.

      Returns:
      must not null.
      Throws:
      XMLStreamException
    • readAsJAXB

      public <T> T readAsJAXB(jakarta.xml.bind.Unmarshaller unmarshaller) throws jakarta.xml.bind.JAXBException
      Description copied from interface: Header
      Reads the header as a JAXB object by using the given unmarshaller.
      Specified by:
      readAsJAXB in interface Header
      Overrides:
      readAsJAXB in class AbstractHeaderImpl
      Throws:
      jakarta.xml.bind.JAXBException
    • readAsJAXB

      public <T> T readAsJAXB(XMLBridge<T> bond) throws jakarta.xml.bind.JAXBException
      Description copied from interface: Header
      Reads the header as a data-bond object
      Specified by:
      readAsJAXB in interface Header
      Overrides:
      readAsJAXB in class AbstractHeaderImpl
      Throws:
      jakarta.xml.bind.JAXBException
    • writeTo

      public void writeTo(XMLStreamWriter sw) throws XMLStreamException
      Description copied from interface: Header
      Writes out the header as a fragment.
      Throws:
      XMLStreamException - if the operation fails for some reason. This leaves the writer to an undefined state.
    • writeTo

      public void writeTo(jakarta.xml.soap.SOAPMessage saaj) throws jakarta.xml.soap.SOAPException
      Description copied from interface: Header
      Writes out the header to the given SOAPMessage.

      Sometimes a Message needs to produce itself as SOAPMessage, in which case each header needs to turn itself into a header.

      Throws:
      jakarta.xml.soap.SOAPException - if the operation fails for some reason. This leaves the writer to an undefined state.
    • writeTo

      public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException
      Description copied from interface: Header
      Writes out the header as SAX events.

      Sometimes a Message needs to produce SAX events, and this method is necessary for headers to participate to it.

      A header is responsible for producing the SAX events for its part, including startPrefixMapping and endPrefixMapping, but not startDocument/endDocument.

      Note that SAX contract requires that any error that does NOT originate from ContentHandler (meaning any parsing error and etc) must be first reported to ErrorHandler. If the SAX event production cannot be continued and the processing needs to abort, the code may then throw the same SAXParseException reported to ErrorHandler.

      Parameters:
      contentHandler - The ContentHandler that receives SAX events.
      errorHandler - The ErrorHandler that receives parsing errors.
      Throws:
      SAXException