soapdust
Class Client

java.lang.Object
  extended by soapdust.Client

public class Client
extends java.lang.Object

Instances of this class allow to query a remote soap server.


Constructor Summary
Client()
           
 
Method Summary
static void activeTraceMode(boolean active)
          Avoid using this method if you are not interested in the result.
 ComposedValue call(java.lang.String operation)
          Calls a remote operation without parameters.
 ComposedValue call(java.lang.String operation, ComposedValue parameters)
          Calls a remote operation.
protected  void customizeHttpConnectionBeforeCall(java.net.HttpURLConnection connection)
          Override this method if you want to customize the http connection.
 void explain(java.io.OutputStream out)
           
 void explain(java.io.Writer out)
          Displays a description of the remote soap service from its wsdl.
 void setEndPoint(java.lang.String url)
          Set the url of the remote service to query.
 void setPassword(java.lang.String password)
          Set a password for BASIC-AUTH authentication.
 void setUsername(java.lang.String userName)
          Set a user name for BASIC-AUTH authentication.
 void setWsdlUrl(java.lang.String wsdlUrl)
          Sets a wsdl url for this client.
 void setWsdlUrlOverrideCache(java.lang.String wsdlUrl)
          Avoid using this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client

public Client()
Method Detail

setWsdlUrl

public void setWsdlUrl(java.lang.String wsdlUrl)
                throws java.io.IOException,
                       MalformedWsdlException
Sets a wsdl url for this client. It is the url this client will use to get the wsdl describing the remote soap service. You must set this url before being able to call remote service or get explanation about remote service. Getting wdsl and analysing them is an expensive operation. For this reason, a cache of service descriptions is shared among all Client instances. The key in this cache is the wsdl url. This method will try to get the service description from the cache first, using the wsdl url as key. Then, only if no service description can be found, will it get the wsdl from the url and analyse it to store service description in the cache. This cache mechanism is thread safe. The cache uses a WeakHashMap so that its entries will be automatically dropped from memory if not used or memory needed.

Parameters:
wsdlUrl - the url to get wsdl from.
Throws:
java.io.IOException - if the wsdl is not reachable for any reason.
MalformedWsdlException - if it can not analyse the wsdl.
See Also:
explain, call, WeakHashMap

setEndPoint

public void setEndPoint(java.lang.String url)
                 throws java.net.MalformedURLException
Set the url of the remote service to query. You must set this url before trying to call any method.

Parameters:
url - of the end point of the remote service.
Throws:
java.net.MalformedURLException

explain

public void explain(java.io.Writer out)
             throws java.io.IOException
Displays a description of the remote soap service from its wsdl. You must set a wsdl url before being able to call this method. The description is written in out. You are responsible to close out. Ex: client.explain(System.out);

Parameters:
out - the Writer to print description to.
Throws:
java.io.IOException

explain

public void explain(java.io.OutputStream out)
             throws java.io.IOException
Parameters:
out -
Throws:
java.io.IOException
See Also:
explain(Writer)

call

public ComposedValue call(java.lang.String operation)
                   throws FaultResponseException,
                          java.io.IOException,
                          MalformedResponseException
Calls a remote operation without parameters. The operation is identified by the given operation parameter.

Parameters:
operation - the remote operation to call
Returns:
the response of the remote server in a ComposedValue
Throws:
FaultResponseException - if the remote server returns a SOAP fault
java.io.IOException - in case of problem during communication with remote server
MalformedResponseException - if the remote server returns a malformed, non-soap response.
See Also:
to have information about the remote service available operations.

call

public ComposedValue call(java.lang.String operation,
                          ComposedValue parameters)
                   throws FaultResponseException,
                          java.io.IOException,
                          MalformedResponseException
Calls a remote operation. The operation is identified by the given operation parameter. Parameters to use for the operation are specified in the given parameters.

Parameters:
operation - the remote operation to call
parameters - the parameters to transmit
Returns:
the response of the remote server in a ComposedValue
Throws:
FaultResponseException - if the remote server returns a SOAP fault
java.io.IOException - in case of problem during communication with remote server
MalformedResponseException - if the remote server returns a malformed, non-soap response.
See Also:
to have information about the remote service available operations and expected parameters.

setUsername

public void setUsername(java.lang.String userName)
Set a user name for BASIC-AUTH authentication.

Parameters:
userName -

setPassword

public void setPassword(java.lang.String password)
Set a password for BASIC-AUTH authentication.

Parameters:
password -

setWsdlUrlOverrideCache

public void setWsdlUrlOverrideCache(java.lang.String wsdlUrl)
                             throws java.io.IOException,
                                    MalformedWsdlException
Avoid using this method. Prefer setWsdlUrl() instead. This method is only usefull if you want to override a service description previously stored in cache for the given wsdlUrl.

Parameters:
wsdlUrl -
Throws:
java.io.IOException
MalformedWsdlException
See Also:
setWsdlUrl

customizeHttpConnectionBeforeCall

protected void customizeHttpConnectionBeforeCall(java.net.HttpURLConnection connection)
Override this method if you want to customize the http connection. For instance you may set a connect or read timeout.

Parameters:
connection - the HttpURLConnection to customize

activeTraceMode

public static void activeTraceMode(boolean active)
Avoid using this method if you are not interested in the result. This may have performance penalty. Change the trace mode status for all Client instances. The trace mode defaults to false. When trace mode is activated, every MalformedResponseException thrown by a Client will contain the data (as a byte array) received from the remote server. This may have a performance penalty since it implies that all the data sent by the server be saved before trying to parse it.

Parameters:
active -