Class Messages

java.lang.Object
com.sun.xml.ws.api.message.Messages

public abstract class Messages extends Object
Factory methods for various Message implementations.

This class provides various methods to create different flavors of Message classes that store data in different formats.

This is a part of the JAX-WS RI internal API so that Tube implementations can reuse the implementations done inside the JAX-WS.

If you find some of the useful convenience methods missing from this class, please talk to us.

Author:
Kohsuke Kawaguchi
  • Method Details

    • create

      @Deprecated public static Message create(jakarta.xml.bind.JAXBContext context, Object jaxbObject, SOAPVersion soapVersion)
      Deprecated.
      Creates a Message backed by a JAXB bean.
      Parameters:
      context - The context to be used to produce infoset from the object. Must not be null.
      jaxbObject - The JAXB object that represents the payload. must not be null. This object must be bound to an element (which means it either is a JAXBElement or an instanceof a class with XmlRootElement).
      soapVersion - The SOAP version of the message. Must not be null.
    • createRaw

      @Deprecated public static Message createRaw(jakarta.xml.bind.JAXBContext context, Object jaxbObject, SOAPVersion soapVersion)
      Deprecated.
      For use when creating a Dispatch object with an unknown JAXB implementation for he JAXBContext parameter.
    • create

      public static Message create(jakarta.xml.soap.SOAPMessage saaj)
      Creates a Message backed by a SAAJ SOAPMessage object.

      If the SOAPMessage contains headers and attachments, this method does the right thing.

      Parameters:
      saaj - The SOAP message to be represented as a Message. Must not be null. Once this method is invoked, the created Message will own the SOAPMessage, so it shall never be touched directly.
    • createUsingPayload

      public static Message createUsingPayload(Source payload, SOAPVersion ver)
      Creates a Message using Source as payload.
      Parameters:
      payload - Source payload is Message's payload Must not be null. Once this method is invoked, the created Message will own the Source, so it shall never be touched directly.
      ver - The SOAP version of the message. Must not be null.
    • createUsingPayload

      public static Message createUsingPayload(XMLStreamReader payload, SOAPVersion ver)
      Creates a Message using XMLStreamReader as payload.
      Parameters:
      payload - XMLStreamReader payload is Message's payload Must not be null. Once this method is invoked, the created Message will own the XMLStreamReader, so it shall never be touched directly.
      ver - The SOAP version of the message. Must not be null.
    • createUsingPayload

      public static Message createUsingPayload(Element payload, SOAPVersion ver)
      Creates a Message from an Element that represents a payload.
      Parameters:
      payload - The element that becomes the child element of the SOAP body. Must not be null.
      ver - The SOAP version of the message. Must not be null.
    • create

      public static Message create(Element soapEnvelope)
      Creates a Message from an Element that represents the whole SOAP message.
      Parameters:
      soapEnvelope - The SOAP envelope element.
    • create

      public static Message create(Source envelope, SOAPVersion soapVersion)
      Creates a Message using Source as entire envelope.
      Parameters:
      envelope - Source envelope is used to create Message Must not be null. Once this method is invoked, the created Message will own the Source, so it shall never be touched directly.
    • createEmpty

      public static Message createEmpty(SOAPVersion soapVersion)
      Creates a Message that doesn't have any payload.
    • create

      @NotNull public static Message create(@NotNull XMLStreamReader reader)
      Creates a Message from XMLStreamReader that points to the start of the envelope.
      Parameters:
      reader - can point to the start document or the start element (of <s:Envelope>)
    • create

      @NotNull public static Message create(@NotNull com.sun.xml.stream.buffer.XMLStreamBuffer xsb)
      Creates a Message from XMLStreamBuffer that retains the whole envelope infoset.
      Parameters:
      xsb - This buffer must contain the infoset of the whole envelope.
    • create

      public static Message create(Throwable t, SOAPVersion soapVersion)
      Creates a Message that represents an exception as a fault. The created message reflects if t or t.getCause() is SOAPFaultException. creates a fault message with default faultCode env:Server if t or t.getCause() is not SOAPFaultException. Otherwise, it use SOAPFaultException's faultCode
      Returns:
      Always non-null. A message that wraps this Throwable.
    • create

      public static Message create(jakarta.xml.soap.SOAPFault fault)
      Creates a fault Message.

      This method is not designed for efficiency, and we don't expect to be used for the performance critical codepath.

      Parameters:
      fault - The populated SAAJ data structure that represents a fault in detail.
      Returns:
      Always non-null. A message that wraps this SOAPFault.
    • createAddressingFaultMessage

      @Deprecated public static Message createAddressingFaultMessage(WSBinding binding, QName missingHeader)
    • createAddressingFaultMessage

      public static Message createAddressingFaultMessage(WSBinding binding, Packet p, QName missingHeader)
      Creates a fault Message that captures the code/subcode/subsubcode defined by WS-Addressing if one of the expected WS-Addressing headers is missing in the message
      Parameters:
      binding - WSBinding
      p - Packet that was missing a WS-Addressing header.
      missingHeader - The missing WS-Addressing Header
      Returns:
      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
    • create

      public static Message create(@NotNull String unsupportedAction, @NotNull AddressingVersion av, @NotNull SOAPVersion sv)
      Creates a fault Message that captures the code/subcode/subsubcode defined by WS-Addressing if wsa:Action is not supported.
      Parameters:
      unsupportedAction - The unsupported Action. Must not be null.
      av - The WS-Addressing version of the message. Must not be null.
      sv - The SOAP Version of the message. Must not be null.
      Returns:
      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
    • create

      @NotNull public static Message create(@NotNull SOAPVersion soapVersion, @NotNull jakarta.xml.ws.ProtocolException pex, @Nullable QName faultcode)
      To be called to convert a ProtocolException and faultcode for a given SOAPVersion in to a Message.
      Parameters:
      soapVersion - SOAPVersion.SOAP_11 or SOAPVersion.SOAP_12
      pex - a ProtocolException
      faultcode - soap faultcode. Its ignored if the ProtocolException instance is SOAPFaultException and it has a faultcode present in the underlying SOAPFault.
      Returns:
      Message representing SOAP fault