com.webmethods.caf.wsclient
Class WSClient

java.lang.Object
  extended by com.webmethods.caf.wsclient.WSClient

public class WSClient
extends Object

WSClient is the singleton where you perform the following: 1) Initialize the Library and set any custom params 2) Register custom IWSProxyFactories 3) Register your logging / error callback implementations 3) Obtain the runtime interfaces to your target webservices
Typical usage might be where the cache is used, sessions are reused, and the system user is used

IMyWebService myWebService = (IMyWebService)WSClient.getProxy(IMyWebService.class, wsdlURL, endPointURL); Object results = myWebService.runWebService(myParams); In this instance, the sessions are resused and the system user is used, but dont' use the cache IMyWebService myWebService = (IMyWebService)WSClient.getProxy(IMyWebService.class, wsdlURL, endPointURL, false); Object results = myWebService.runWebService(myParams); Typical initialization would be WSClient.init(new WSClientConfig(); WSClient.setArtifactFactory(<yourArtifactFactory>); For SAML authenicated invocations, an IArtifactFactory and security service endpoint are required WSClientConfig config = new WSClientConfig(); config.setArtifactFactory(factory); config.setSamlSecurityEndpoint(getSecurityProviderEndpoint()); config.setAuthCredentials(new AuthCredentials(true)); WSClient.init(config);


Field Summary
static Logger logger
           
static String WSCLIENT_MOD
          Module name of WSClient for logging purposes
 
Method Summary
 void _addFailedAuthCallback(IFailedAuthCallback callbackObj)
          Add a callback listener to be invoked when an auth failure occurs
protected  IWSCacheManager _getCacheManager()
          Internal instance method.
protected  WSClientConfig _getClientConfig()
          Get the current client configuration object
protected  IWSProxyFactory _getFactory(Class clazz, String clientID)
          Internal instance method.
protected  IWSClientSessionManager _getSessionManager()
          Internal instance method.
 void _registerFactory(Class clazz, String clientID, IWSProxyFactory proxyFactory)
          Internal instance method.
 void _removeFailedAuthCallback(IFailedAuthCallback callbackObj)
          Remove a previously registered auth failure callback listener
protected  void _unRegisterFactory(Class clazz, String clientID)
          Internal instance method.
static void addFailedAuthCallback(IFailedAuthCallback callbackObj)
          Helper static method to add failed auth callback listeners
static void addLogListener(ILogListener listener)
          Convenience method to add a logging listener to the WSClient Logging events within the WSClient are fired to the log listeners as events.
static void flushAllCache()
          Flush all WsClient caches for all interfaces
static IWSCacheManager getCacheManager()
          Get a reference to the Cache Manager object.
static WSClientConfig getClientConfig()
          Helper static method to retrieve the WSClientConfig configuration object
static IWSProxyFactory getFactory(Class clazz)
          Returns the appropriate IWSProxyFactory for this interface class, or the default implementation
static IWSProxyFactory getFactory(Class clazz, String clientID)
          Returns the appropriate IWSProxyFactory for this interface class and client ID, or the default implementation
protected static String getFactoryMapKey(Class clazz, String clientID)
           
static List getFailedAuthListeners()
          Get the list of registered Auth failure callback objects
static Object getProxy(Class clazz, String wsdlURL, String endPointURL)
          A convenience method that first obtains the default IWSProxyFactory and and returns an instance of a IWSClientProxy
static Object getProxy(Class clazz, String wsdlURL, String[] mapURLs, String endPointURL)
          A convenience method that first obtains the default IWSProxyFactory and and returns an instance of a IWSClientProxy
static Object getProxy(Class clazz, String wsdlURL, String[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching and session re-use
static Object getProxy(Class clazz, String wsdlURL, String[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession, AuthCredentials authCredentials)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, as well as supplying credentials that override those of the proxy factory.
static Object getProxy(Class clazz, String wsdlURL, String[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession, int socketTimeout, AuthCredentials authCredentials)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, credentials that override those of the proxy factory, and override the socket timeout of the web service request.
static Object getProxy(Class clazz, String wsdlURL, String endPointURL, boolean useCache)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching
static Object getProxy(Class clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching and session re-use
static Object getProxy(Class clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession, AuthCredentials authCredentials)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, as well as supplying credentials that override those of the proxy factory.
static Object getProxy(Class clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession, int socketTimeout, AuthCredentials authCredentials)
          A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, credentials that override those of the proxy factory, and override the socket timeout of the web service request.
static IWSClientSessionManager getSessionManager()
          Get a reference to the Session Manager object.
static void init(WSClientConfig clientConfig)
          Initialize the default WSClient instance with the supplied configuration
protected static WSClient instance()
          Get the default static instance of WSClient
static boolean isInit()
          Has the default instance of WSClient been initialized
static void registerFactory(Class clazz, IWSProxyFactory proxyFactory)
          Registers a new IWSProxyFactory for the specified class
static void registerFactory(Class clazz, String clientID, IWSProxyFactory proxyFactory)
          Registers a new IWSProxyFactory for the specified class
static void removeFailedAuthCallback(IFailedAuthCallback callbackObj)
          Helper static method to remove failed auth callback listeners
static void removeLogListener(ILogListener listener)
          Convenience method to remove a logging listener to the WSClient Logging events within the WSClient are fired to the log listeners as events.
static void shutdown()
           
static void unRegisterFactory(Class clazz)
          Unregisters an IWSProxyFactory
static void unRegisterFactory(Class clazz, String clientID)
          Unregisters an IWSProxyFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static Logger logger

WSCLIENT_MOD

public static final String WSCLIENT_MOD
Module name of WSClient for logging purposes

Method Detail

init

public static void init(WSClientConfig clientConfig)
Initialize the default WSClient instance with the supplied configuration

Parameters:
clientConfig - a WSClient configuration object containing options of this WSClient instance

shutdown

public static void shutdown()

isInit

public static boolean isInit()
Has the default instance of WSClient been initialized

Returns:
true if the default instance of WSClient has been initialized, otherwise false

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String endPointURL)
                       throws WSClientException
A convenience method that first obtains the default IWSProxyFactory and and returns an instance of a IWSClientProxy

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
endPointURL - the web service endpoint URL as a string
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String[] mapURLs,
                              String endPointURL)
                       throws WSClientException
A convenience method that first obtains the default IWSProxyFactory and and returns an instance of a IWSClientProxy

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
mapURLs - an array of web service .map file URLs
endPointURL - the web service endpoint URL as a string
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String endPointURL,
                              boolean useCache)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String, boolean)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching and session re-use

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String, boolean, boolean)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String[] mapURLs,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy and allows the enable/disable of result caching and session re-use

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
mapURLs - an array of web service .map file URLs
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String[], String, boolean, boolean)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession,
                              AuthCredentials authCredentials)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, as well as supplying credentials that override those of the proxy factory.

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
authCredentials - credentials for authentication with the web servic provider. If null, the credentials set in the proxy factory will be used.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String, boolean, boolean, AuthCredentials)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String[] mapURLs,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession,
                              AuthCredentials authCredentials)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, as well as supplying credentials that override those of the proxy factory.

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
mapURLs - an array of web service .map file URLs
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
authCredentials - credentials for authentication with the web service provider. If null, the credentials set in the proxy factory will be used.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String[], String, boolean, boolean, AuthCredentials)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession,
                              int socketTimeout,
                              AuthCredentials authCredentials)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, credentials that override those of the proxy factory, and override the socket timeout of the web service request.

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
socketTimeout - the timeout of the web service request (in seconds)
authCredentials - credentials for authentication with the web service provider. If null, the credentials set in the proxy factory will be used.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String, boolean, boolean, int, AuthCredentials)

getProxy

public static Object getProxy(Class clazz,
                              String wsdlURL,
                              String[] mapURLs,
                              String endPointURL,
                              boolean useCache,
                              boolean reuseSession,
                              int socketTimeout,
                              AuthCredentials authCredentials)
                       throws WSClientException
A convenience method that first obtains the IWSProxyFactory and and returns an instance of a IWSClientProxy, allows the enable/disable of result caching and session re-use, credentials that override those of the proxy factory, and override the socket timeout of the web service request.

Parameters:
clazz - the web service interface to proxy with WSClient
wsdlURL - the URL of the web service WSDL file as a string
mapURLs - an array of web service .map file URLs
endPointURL - the web service endpoint URL as a string
useCache - true to enable caching of the web service results
reuseSession - true to enable reuse of sessions with the web service endpoint. False to create a new session on each web service invocation.
socketTimeout - the timeout of the web service request (in seconds)
authCredentials - credentials for authentication with the web service provider. If null, the credentials set in the proxy factory will be used.
Returns:
a dynamic instance proxy wrapping the web service interface. This proxy also extends the IWSClientProxy interface.
Throws:
WSClientException
See Also:
IWSProxyFactory.getProxy(Class, String, String[], String, boolean, boolean, int, AuthCredentials)

instance

protected static WSClient instance()
Get the default static instance of WSClient

Returns:
the default static instace of WSClient

registerFactory

public static void registerFactory(Class clazz,
                                   IWSProxyFactory proxyFactory)
Registers a new IWSProxyFactory for the specified class

Parameters:
clazz - the param used in calls to WSClient.getFactory(Class)
proxyFactory - the custom implemenation of IWSProxyFactory

registerFactory

public static void registerFactory(Class clazz,
                                   String clientID,
                                   IWSProxyFactory proxyFactory)
Registers a new IWSProxyFactory for the specified class

Parameters:
clazz - the param used in calls to WSClient.getFactory(Class)
clientID - clientID - used to separate factories by client if desired
proxyFactory - the custom implemenation of IWSProxyFactory

_registerFactory

public void _registerFactory(Class clazz,
                             String clientID,
                             IWSProxyFactory proxyFactory)
Internal instance method. Registers a new IWSProxyFactory for the specified class

Parameters:
clazz - the param used in calls to WSClient.getFactory(Class)
clientID - the param used to seperate factory caches by client (option
proxyFactory - the custom implemenation of IWSProxyFactory

_unRegisterFactory

protected void _unRegisterFactory(Class clazz,
                                  String clientID)
Internal instance method. Unregisters an IWSProxyFactory

Parameters:
clazz - the param used in calls to WSClient.getFactory(Class)

unRegisterFactory

public static void unRegisterFactory(Class clazz)
Unregisters an IWSProxyFactory

Parameters:
clazz -

unRegisterFactory

public static void unRegisterFactory(Class clazz,
                                     String clientID)
Unregisters an IWSProxyFactory

Parameters:
clazz - the interface class to unregister
clientID - a client ID identifier to allow separate client caches

_getFactory

protected IWSProxyFactory _getFactory(Class clazz,
                                      String clientID)
Internal instance method. Returns the appropriate IWSProxyFactory for this interface class, or the default implementation

Parameters:
clazz - The web service interface class to proxy
clazz - a string ID to separate proxy caches
Returns:
an instance of IWSProxyFactory associated with the specified interface

getFactory

public static IWSProxyFactory getFactory(Class clazz)
Returns the appropriate IWSProxyFactory for this interface class, or the default implementation

Parameters:
clazz - The web service interface class to proxy
Returns:
an instance of IWSProxyFactory associated with the specified interface

getFactory

public static IWSProxyFactory getFactory(Class clazz,
                                         String clientID)
Returns the appropriate IWSProxyFactory for this interface class and client ID, or the default implementation

Parameters:
clazz - The web service interface class to proxy
clientID - - a string identifier to allow separation of proxy factories by client
Returns:
an instance of IWSProxyFactory associated with the specified interface

_getSessionManager

protected IWSClientSessionManager _getSessionManager()
Internal instance method. Get a reference to the Session Manager object.

Returns:
instance of IWSClientSessionManager

getSessionManager

public static IWSClientSessionManager getSessionManager()
Get a reference to the Session Manager object.

Returns:
instance of IWSClientSessionManager

_getCacheManager

protected IWSCacheManager _getCacheManager()
Internal instance method.

Returns:
instance of IWSCacheManager

getCacheManager

public static IWSCacheManager getCacheManager()
Get a reference to the Cache Manager object.

Returns:
instance of IWSCacheManager

addLogListener

public static void addLogListener(ILogListener listener)
Convenience method to add a logging listener to the WSClient Logging events within the WSClient are fired to the log listeners as events.

Parameters:
listener - an instance of ILogListener

removeLogListener

public static void removeLogListener(ILogListener listener)
Convenience method to remove a logging listener to the WSClient Logging events within the WSClient are fired to the log listeners as events.

Parameters:
listener - the instance of ILogListener to unregister

_getClientConfig

protected WSClientConfig _getClientConfig()
Get the current client configuration object

Returns:

getClientConfig

public static WSClientConfig getClientConfig()
Helper static method to retrieve the WSClientConfig configuration object

Returns:
instance of WSClientConfig used to configure this instance of WSClient

addFailedAuthCallback

public static void addFailedAuthCallback(IFailedAuthCallback callbackObj)
Helper static method to add failed auth callback listeners

Parameters:
callbackObj - IFailedAuthCallback instance to register
See Also:
for implementation details

_addFailedAuthCallback

public void _addFailedAuthCallback(IFailedAuthCallback callbackObj)
Add a callback listener to be invoked when an auth failure occurs

Parameters:
callbackObj - IFailedAuthCallback instance to register
See Also:
for implementation details

removeFailedAuthCallback

public static void removeFailedAuthCallback(IFailedAuthCallback callbackObj)
Helper static method to remove failed auth callback listeners

Parameters:
callbackObj - IFailedAuthCallback instance to unregister
See Also:
for implementation details

_removeFailedAuthCallback

public void _removeFailedAuthCallback(IFailedAuthCallback callbackObj)
Remove a previously registered auth failure callback listener

Parameters:
callbackObj - IFailedAuthCallback instance to unregister

getFailedAuthListeners

public static List getFailedAuthListeners()
Get the list of registered Auth failure callback objects

Returns:
an List of IFailedAuthCallback implementations that have registered with this instance of WSClient

flushAllCache

public static void flushAllCache()
Flush all WsClient caches for all interfaces


getFactoryMapKey

protected static String getFactoryMapKey(Class clazz,
                                         String clientID)