Package org.somda.sdc.dpws.soap
Class SoapUtil
- java.lang.Object
-
- org.somda.sdc.dpws.soap.SoapUtil
-
public class SoapUtil extends Object
SOAP utility functions.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SoapMessagecreateMessage()Creates an empty SOAP message.SoapMessagecreateMessage(String wsaAction)Creates a SOAP message with a specific action and empty body.SoapMessagecreateMessage(String wsaAction, Object firstBodyElement)Creates a SOAP message with a specific action and first body element.SoapMessagecreateMessage(String wsaAction, String wsaTo)Creates a SOAP message with a specific action and to element.SoapMessagecreateMessage(String wsaAction, String wsaTo, Object firstBodyElement)Creates a SOAP message with a specific action, to and first body element.SoapMessagecreateMessage(String wsaAction, String wsaTo, Object firstBodyElement, ReferenceParametersType referenceParameters)Creates a SOAP message with a specific action, to, the first body element as well as reference parameters.SoapMessagecreateMessage(Envelope envelope)Creates a SOAP message with the given envelope.StringcreateRandomUuidUri()Creates a URI with a random UUID.StringcreateUriFromUuid(UUID uuid)Creates a URI representation of a UUID.UUIDcreateUuidFromUri(String uri)Converts from a URI to a UUID.<T> Optional<T>getBody(SoapMessage src, Class<T> destType)Tries to retrieve SOAP body element fromSoapMessage.<T> voidsetBody(T element, SoapMessage dest)Stores element in destined SOAP body.voidsetWsaAction(SoapMessage response, String action)Takes a response message and sets the WS-Addressing action header.
-
-
-
Method Detail
-
setBody
public <T> void setBody(T element, SoapMessage dest)Stores element in destined SOAP body.- Type Parameters:
T- the type of element inelement.- Parameters:
element- element to store indest.dest- SOAP message to storeelementin.
-
getBody
public <T> Optional<T> getBody(SoapMessage src, Class<T> destType)
Tries to retrieve SOAP body element fromSoapMessage.- 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.
-
-