Class SoapUtil

java.lang.Object
org.somda.sdc.dpws.soap.SoapUtil

public class SoapUtil extends Object
SOAP utility functions.
  • Method Details

    • setBody

      public <T> void setBody(T element, SoapMessage dest)
      Stores element in destined SOAP body.
      Type Parameters:
      T - the type of element in element.
      Parameters:
      element - element to store in dest.
      dest - SOAP message to store element in.
    • getBody

      public <T> Optional<T> getBody(SoapMessage src, Class<T> destType)
      Tries to retrieve SOAP body element from SoapMessage.
      Type Parameters:
      T - the type to convert to.
      Parameters:
      src - the source message.
      destType - type of first element in body.
      Returns:
      an instance of T, or Optional.empty() if conversion fails.
    • createUriFromUuid

      public String createUriFromUuid(UUID uuid)
      Creates a URI representation of a UUID.
      Parameters:
      uuid - the UUID to convert.
      Returns:
      a UUID URN.
    • createUuidFromUri

      public UUID createUuidFromUri(String uri)
      Converts from a URI to a UUID.
      Parameters:
      uri - the URI to convert.
      Returns:
      the converted UUID.
      Throws:
      RuntimeException - in case of misformatted URIs.
    • createRandomUuidUri

      public String createRandomUuidUri()
      Creates a URI with a random UUID.
      Returns:
      the UUID URN.
    • setWsaAction

      public void setWsaAction(SoapMessage response, String action)
      Takes a response message and sets the WS-Addressing action header.
      Parameters:
      response - the SOAP response message.
      action - the action to put to the response message.
    • createMessage

      public SoapMessage createMessage()
      Creates an empty SOAP message.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(Envelope envelope)
      Creates a SOAP message with the given envelope.
      Parameters:
      envelope - the envelope to put to the SOAP message.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(String wsaAction)
      Creates a SOAP message with a specific action and empty body.
      Parameters:
      wsaAction - the action header to set.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(String wsaAction, @Nullable Object firstBodyElement)
      Creates a SOAP message with a specific action and first body element.
      Parameters:
      wsaAction - the action header to set.
      firstBodyElement - the first child of the body element.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(String wsaAction, String wsaTo)
      Creates a SOAP message with a specific action and to element.
      Parameters:
      wsaAction - the action header to set.
      wsaTo - the to header to set.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(String wsaAction, String wsaTo, @Nullable Object firstBodyElement)
      Creates a SOAP message with a specific action, to and first body element.
      Parameters:
      wsaAction - the action header to set.
      wsaTo - the to header to set.
      firstBodyElement - the first child of the body element.
      Returns:
      a new SOAP message.
    • createMessage

      public SoapMessage createMessage(String wsaAction, String wsaTo, @Nullable Object firstBodyElement, @Nullable ReferenceParametersType referenceParameters)
      Creates a SOAP message with a specific action, to, the first body element as well as reference parameters.
      Parameters:
      wsaAction - the action header to set.
      wsaTo - the to header to set.
      firstBodyElement - the first child of the body element.
      referenceParameters - reference parameters to attach to the message.
      Returns:
      a new SOAP message.