Package uk.ac.starlink.registry
Class SoapClient
- java.lang.Object
-
- uk.ac.starlink.registry.SoapClient
-
public class SoapClient extends java.lang.Object
Lightweight, freestanding SOAP client which can make simple requests and allows the responses to be processed as a SAX stream. Logging of sent and received XML can optionally be performed by using thesetEchoStream(java.io.OutputStream)
method. Probably, there is much of SOAP that this doesn't implement, but it works well enough to write a registry client on top of it.Why write yet another SOAP client? Last time I tried to get Axis to do this (stream processing of the response) it took me several days of misery, and still didn't work. The actual job I need to do here is quite straightforward, so it's not difficult to write it from scratch.
- Since:
- 9 Dec 2009
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description SoapClient(java.net.URL endpoint)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(SoapRequest request, org.xml.sax.ContentHandler responseBodyHandler)
Sends a SOAP request, and passes the response body to a supplied SAX content handler.java.net.URL
getEndpoint()
Returns the endpoint of the service this client talks to.void
setEchoStream(java.io.OutputStream echoStream)
Sets an output stream to which all input and output HTTP traffic will be logged.
-
-
-
Method Detail
-
getEndpoint
public java.net.URL getEndpoint()
Returns the endpoint of the service this client talks to.- Returns:
- SOAP endpoint
-
setEchoStream
public void setEchoStream(java.io.OutputStream echoStream)
Sets an output stream to which all input and output HTTP traffic will be logged. If null (the default), no such logging is performed.- Parameters:
echoStream
- logging destination stream
-
execute
public void execute(SoapRequest request, org.xml.sax.ContentHandler responseBodyHandler) throws java.io.IOException, org.xml.sax.SAXException
Sends a SOAP request, and passes the response body to a supplied SAX content handler. It will be parsed by a SAX parser which is namespace aware, and is not validating.- Parameters:
request
- SOAP request to sendresponseBodyHandler
- a SAX ContentHandler which will be invoked on the content of the <soapenv:Body> response element in case of a successful (200) response- Throws:
java.io.IOException
org.xml.sax.SAXException
-
-