Class SaajUtils

java.lang.Object
org.springframework.ws.soap.saaj.support.SaajUtils

public abstract class SaajUtils extends Object
Collection of generic utility methods to work with SAAJ. Includes conversion from SAAJ Name objects to QNames and vice-versa, and SAAJ version checking.
Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static jakarta.xml.soap.SOAPEnvelope
    getEnvelope(jakarta.xml.soap.SOAPElement element)
    Returns the SAAJ SOAPEnvelope for the given element.
    static jakarta.xml.soap.SOAPElement
    getFirstBodyElement(jakarta.xml.soap.SOAPBody body)
    Returns the first child element of the given body.
    static int
    Gets the SAAJ version.
    static int
    getSaajVersion(jakarta.xml.soap.SOAPElement soapElement)
    Gets the SAAJ version for the specified SOAPElement.
    static int
    getSaajVersion(jakarta.xml.soap.SOAPMessage soapMessage)
    Gets the SAAJ version for the specified SOAPMessage.
    static String
    Returns the SAAJ version as a String.
    static jakarta.xml.soap.SOAPMessage
    loadMessage(org.springframework.core.io.Resource resource, jakarta.xml.soap.MessageFactory messageFactory)
    Loads a SAAJ SOAPMessage from the given resource with a given message factory.
    static jakarta.xml.soap.Name
    toName(QName qName, jakarta.xml.soap.SOAPElement resolveElement)
    Converts a QName to a Name.
    static QName
    toQName(jakarta.xml.soap.Name name)
    Converts a jakarta.xml.soap.Name to a javax.xml.namespace.QName.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SaajUtils

      public SaajUtils()
  • Method Details

    • getSaajVersion

      public static int getSaajVersion()
      Gets the SAAJ version. Returns SAAJ_13 as of Spring-WS 2.2.
      Returns:
      a code comparable to the SAAJ_XX codes in this class
    • getSaajVersion

      public static int getSaajVersion(jakarta.xml.soap.SOAPMessage soapMessage) throws jakarta.xml.soap.SOAPException
      Gets the SAAJ version for the specified SOAPMessage. Returns SAAJ_13 as of Spring-WS 2.2.
      Returns:
      a code comparable to the SAAJ_XX codes in this class
      Throws:
      jakarta.xml.soap.SOAPException
      See Also:
    • getSaajVersion

      public static int getSaajVersion(jakarta.xml.soap.SOAPElement soapElement)
      Gets the SAAJ version for the specified SOAPElement. Returns SAAJ_13 as of Spring-WS 2.2.
      Returns:
      a code comparable to the SAAJ_XX codes in this class
      See Also:
    • getSaajVersionString

      public static String getSaajVersionString()
      Returns the SAAJ version as a String. The returned string will be "SAAJ 1.3", "SAAJ 1.2", or "SAAJ 1.1".
      Returns:
      a string representation of the SAAJ version
      See Also:
    • toName

      public static jakarta.xml.soap.Name toName(QName qName, jakarta.xml.soap.SOAPElement resolveElement) throws jakarta.xml.soap.SOAPException
      Converts a QName to a Name. A SOAPElement is required to resolve namespaces.
      Parameters:
      qName - the QName to convert
      resolveElement - a SOAPElement used to resolve namespaces to prefixes
      Returns:
      the converted SAAJ Name
      Throws:
      jakarta.xml.soap.SOAPException - if conversion is unsuccessful
      IllegalArgumentException - if qName is not fully qualified
    • toQName

      public static QName toQName(jakarta.xml.soap.Name name)
      Converts a jakarta.xml.soap.Name to a javax.xml.namespace.QName.
      Parameters:
      name - the Name to convert
      Returns:
      the converted QName
    • loadMessage

      public static jakarta.xml.soap.SOAPMessage loadMessage(org.springframework.core.io.Resource resource, jakarta.xml.soap.MessageFactory messageFactory) throws jakarta.xml.soap.SOAPException, IOException
      Loads a SAAJ SOAPMessage from the given resource with a given message factory.
      Parameters:
      resource - the resource to read from
      messageFactory - SAAJ message factory used to construct the message
      Returns:
      the loaded SAAJ message
      Throws:
      jakarta.xml.soap.SOAPException - if the message cannot be constructed
      IOException - if the input stream resource cannot be loaded
    • getEnvelope

      public static jakarta.xml.soap.SOAPEnvelope getEnvelope(jakarta.xml.soap.SOAPElement element)
      Returns the SAAJ SOAPEnvelope for the given element.
      Parameters:
      element - the element to return the envelope from
      Returns:
      the envelope, or null if not found
    • getFirstBodyElement

      public static jakarta.xml.soap.SOAPElement getFirstBodyElement(jakarta.xml.soap.SOAPBody body)
      Returns the first child element of the given body.