SOAPSender¶
-
public abstract class
SOAPSender
extends Component implements Runnable¶ The
SOAPSender
is a abstract class for the SOAP-Based protocol client. It reduces the complexity and version incompatible induced from the apache AXIS by using only Built-in java SOAP XML Package. The target developer is for those whose are not familiar with the complex AXIS framework. It is implemented using the event-driven model so that developer are only required to implement several event method. The package is under development and will be standardized in the future release.Author: Twinsen Tsang
Fields¶
log¶
-
protected FileLogger
log
¶ The logger used for log message and exception
See also:
hk.hku.cecid.corvus.util.FileLogger
request¶
-
protected SOAPMessage
request
¶ The SOAP request
response¶
-
protected SOAPMessage
response
¶ The SOAP response
Constructors¶
SOAPSender¶
-
public
SOAPSender
()¶ SPA Constructor. It is used when the SOAP Sender is a component in the spa.
SOAPSender¶
-
public
SOAPSender
(FileLogger l, Data d)¶ Constructor
Parameters: - l – The logger used for log message and exception.
SOAPSender¶
-
public
SOAPSender
(FileLogger l, Data d, String endpoint)¶ Constructor
Parameters: - l – The logger used for log message and exception.
- endpoint – The url of service end point.
SOAPSender¶
-
public
SOAPSender
(FileLogger l, Data d, URL endpoint)¶ Constructor.
Parameters: - l – The logger used for log message and exception.
- endpoint – The url of service end point.
Methods¶
addRequestElementText¶
-
public boolean
addRequestElementText
(String tagName, String tagValue, String nsPrefix, String nsURI)¶ Add SOAP element to body with name and value.
Parameters: - tagName – The tag name of element to be retrieved.
- tagValue – The value of the element to be added.
- nsPrefix – The namespace Prefix
- nsURI – The namespace URI.
Throws: - SOAPException –
Returns: true if the creation and addition is successfully.
addRequestElementText¶
-
public boolean
addRequestElementText
(String parentTagName, String parentNsURI, String tagName, String tagValue, String nsPrefix, String nsURI)¶ Add SOAP element to specify parent element
Parameters: - parentTagName – The tag name of parent element.
- parentNsURI – The namespace URI of parent element.
- tagName – The tag name of element to be retrieved.
- tagValue – The value of the element to be added.
- nsPrefix – The namespace Prefix
- nsURI – The namespace URI.
Throws: - SOAPException –
Returns: true if the creation and linking is successfully.
countResponseElementText¶
-
public int
countResponseElementText
(String tagname, String nsURI)¶ This methods count number of specified
tagname
in the response. It should only be called insideonResponse()
.Parameters: - tagname – The tag name of element to be retrieved.
- nsURI – The namespace URI.
Throws: - SOAPException –
Returns: The element text in the tagname specified.
getCurrentLoopTimes¶
-
public int
getCurrentLoopTimes
()¶ Get what is the current loop times for looping
getRequestElementText¶
-
public String
getRequestElementText
(String tagname, String nsURI, int whichOne)¶ This method should only be called inside
onCreateRequest()
. because the request object will be deleted upon each ws call.Parameters: - tagname – The tag name of element to be retrieved.
- nsURI – The namespace URI.
- whichOne – The nth child element to be returned.
getResponseElementAsList¶
-
public String[]
getResponseElementAsList
(String tagname, String nsURI)¶ This method should only be called inside
onResponse()
. because the response object will be deleted upon each ws call. This method get the element by it’stagname
and return a list of text value inside.Parameters: - tagname – The name of the XML tag to be extraceted.
- nsURI – The namespace URI.
Throws: - SOAPException –
Returns: The elements’ text in the tagname specified.
getResponseElementText¶
-
public String
getResponseElementText
(String tagname, String nsURI, int whichOne)¶ This method should only be called inside
onResponse()
. because the response object will be deleted upon each ws call.Parameters: - tagname – The tag name of element to be retrieved.
- nsURI – The namespace URI.
- whichOne – The nth child element to be returned.
Returns: The element text in the tagname specified.
getSOAPRequest¶
-
protected SOAPMessage
getSOAPRequest
()¶ Get the SOAP request.
Returns: The SOAP Request Body.
getSOAPResponse¶
-
protected SOAPMessage
getSOAPResponse
()¶ Get the SOAP response. The method should only be called inside
onResponse()
.Returns: The SOAP Response Body.
getServiceEndPoint¶
initializeMessage¶
-
public void
initializeMessage
()¶ Implements this method if you want to send messages without much different between other message to sent.
isRequireXMLDeclaraction¶
-
public boolean
isRequireXMLDeclaraction
()¶ return return true if the request requires the XML declaration to sent.
onBeforeRequest¶
-
public void
onBeforeRequest
(SOAPConnection conn, SOAPMessage request)¶ [@EVENT] This method is invoked just before sending the request to Web service endpoints.
Parameters: - conn – The SOAP Connection used for sending SOAP request.
- request – The request created by
onCreateRequest()
.
Throws: - Exception – Any type of exception will be processed at onError(throwable t).
onCreateRequest¶
-
public SOAPMessage
onCreateRequest
()¶ [@EVENT] This method is invoked when the sender is required to sent a SOAP Request for configuration. The default return value is the request in the sender. If developer want to send a custom SOAP request other than the sender SOAP request, override the function and return your customizing SOAP Request. For example, if you want to send a SOAP request always with soap element “test”. Then you should override this function called.
public SOAPMessage onCreateRequest() throws Exception{ SOAPMessage request = MessageFactory.newInstance().createMessage(); .. .. add the element "test". return request; }
Throws: - Exception – Any type of exception will be processed at onError(throwable t).
Returns: javax.xml.SOAPMessage
onEachLoopStart¶
onError¶
onResponse¶
-
public void
onResponse
()¶ [@EVENT] This method is invoked when received the reply SOAP response from the server Developer can use
getSOAPResponse()
to get the SOAP response for self-handling. Otherwise, developer can usegetResponseElementText(String,String,int)
to get the response element text from the response object.Throws: - Exception – Any type of exception will be processed at onError(throwable t).
onStart¶
-
public void
onStart
()¶ [@EVENT] This method is invoked when the sender begins to execute the run method.
resetSOAPRequest¶
-
protected void
resetSOAPRequest
()¶ Reset the request to empty SOAP Body. It is commonly used when for each loop times the request
Throws: - SOAPException –
resetSOAPResponse¶
-
protected void
resetSOAPResponse
()¶ Reset the request to empty SOAP Body. It is commonly used when for each loop times the response.
setBasicAuthentication¶
setLoopTimes¶
-
public void
setLoopTimes
(int loopTimes)¶ Set how many times should the sender to be send.
Parameters: - loopTimes – the new loopTimes.
setRequestDirty¶
-
public void
setRequestDirty
(boolean dirty)¶ Set if the request is dirty. We considered “dirty” as the request has been modified by someone during last sending.
setRequireXMLDeclaraction¶
-
public void
setRequireXMLDeclaraction
(boolean require)¶ Set if the request requires XML declaration at the top of the request. This is equivalent to:
SOAPRequest.setProperty(WRITE_XML_DECLARATION, "true");
Parameters: - require – true if requires XML declaration.
See also:
javax.xml.soap.SOAPMessage.setProperty(String,Object)
,javax.xml.soap.SOAPMessage.WRITE_XML_DECLARATION
setServiceEndPoint¶
setServiceEndPoint¶
setUserObject¶
transformResponseContent¶
-
public PropertyTree
transformResponseContent
()¶ Transform the response into a property tree. It should only be called inside
onResponse()
.Returns: An XML Property tree having the same tag content in the response.