Package com.storedobject.common
Class SOAP
java.lang.Object
com.storedobject.common.SOAP
SOAP client - A simple SOAP utility for sending/receiving/manipulating SOAP messages. The default SOAP
version supported is "1.2".
- Author:
- Syam
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Extract the boolean value of a path within the SOAP Body.void
close()
Close the resources associated with this instance.getBody()
Get the SOAP Body node.getFault()
Get the SOAP Fault node (Available when response is received).Get the SOAP Header node.getHTTP()
Get the HTTP connection associated with this SOAP.Get a node from the SOAP Body.Extract the numeric value of a path within the SOAP Body.final String
Get the current "SOAP-Env" prefix.Extract the text value of a path within the SOAP Body.getXML()
Get the XML associated with this SOAP request.void
request()
Send the request.void
This method is invoked just before the request is sent to the server.void
setConnectTimeout
(int timeout) Set the connection timeout for the HTTP request.void
setPack
(boolean pack) Whether to pack the SOAP XML structure by removing all the unwanted text nodes or not.final void
setPrefixSOAP
(String prefixSOAP) Set the prefix to be used as the "SOAP-Env" prefix.void
setReadTimeout
(int timeout) Sets the read timeout for the HTTP connection.void
setTemplate
(String templateSOAP) Set the SOAP template.boolean
Set a text value to the given path in the body.boolean
Set a text value to the given node if it is a "text node".final void
setVersionSOAP
(SOAP.Version version) Set the SOAP version.Returns the XML associated with this SOAP request in a pretty string format.toString()
-
Constructor Details
-
SOAP
Constructor.- Parameters:
serviceURL
- Service URL.- Throws:
MalformedURLException
-
SOAP
Constructor.- Parameters:
serviceURL
- Service URL.actionSOAP
- SOAP action.- Throws:
MalformedURLException
-
-
Method Details
-
setVersionSOAP
Set the SOAP version.Warning: This should be set before invoking any XML related methods!
- Parameters:
version
- Version.
-
getHTTP
Get the HTTP connection associated with this SOAP.- Returns:
- HTTP connection instance.
-
setPack
public void setPack(boolean pack) Whether to pack the SOAP XML structure by removing all the unwanted text nodes or not. The default value istrue
. Packing reduces human readability.- Parameters:
pack
- True/false.
-
getPrefixSOAP
-
setPrefixSOAP
Set the prefix to be used as the "SOAP-Env" prefix.- Parameters:
prefixSOAP
- Prefix to set.
-
getXML
-
getNode
-
setText
-
setText
Set a text value to the given node if it is a "text node". If the node is not a "text node", the value will be set to its first child if that is a "text node". Else, it will recursively go down until a "text node" is found. Please note that the recursive traversal happens only through the first children.- Parameters:
node
- Node for which value to be set.value
- Value to set.- Returns:
- True if the value was successfully set. Otherwise, false.
-
getText
-
getNumber
-
check
-
getHeader
-
getBody
-
getFault
-
setTemplate
Set the SOAP template. This method allows you to set a template XML for creating the SOAP request.Note: If you don't have a template, you can just construct the XML by adding necessary sub-structures to the Header and/or Body nodes obtained via
getHeader()
/getBody()
.- Parameters:
templateSOAP
- String representing the SOAP. If it is null or empty, a minimal SOAP template is automatically created.- Throws:
Exception
- If the template is not a valid SOAP XML.
-
request
Send the request. After this call, the XML returned bygetXML()
will contain the SOAP response until it is reset via a call tosetTemplate(String)
.- Throws:
Exception
- Raised if any error occurs and in that case, the SOAP structure will be in an erroneous state.
-
requesting
public void requesting()This method is invoked just before the request is sent to the server. You may apply additional controls to the HTTP request. -
close
public void close()Close the resources associated with this instance. This instance may not be used after calling this. -
toString
-
toPrettyString
Returns the XML associated with this SOAP request in a pretty string format.- Returns:
- The XML in pretty string format.
-
setConnectTimeout
public void setConnectTimeout(int timeout) Set the connection timeout for the HTTP request.- Parameters:
timeout
- the connection timeout in milliseconds
-
setReadTimeout
public void setReadTimeout(int timeout) Sets the read timeout for the HTTP connection.- Parameters:
timeout
- The read timeout in milliseconds.
-