Package com.webmethods.caf.wsclient
Class WSClient
java.lang.Object
com.webmethods.caf.wsclient.WSClient
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();
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);
Typical usage might be where the cache is used, sessions are reused, and the system user is used
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic org.slf4j.Logger
static final String
Module name of WSClient for logging purposes -
Method Summary
Modifier and TypeMethodDescriptionvoid
_addFailedAuthCallback
(IFailedAuthCallback callbackObj) Add a callback listener to be invoked when an auth failure occursprotected IWSCacheManager
Internal instance method.protected WSClientConfig
Get the current client configuration objectprotected IWSProxyFactory
_getFactory
(Class<?> clazz, String clientID) Internal instance method.protected IWSClientSessionManager
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 listenerprotected void
_unRegisterFactory
(Class<?> clazz, String clientID) Internal instance method.static void
addFailedAuthCallback
(IFailedAuthCallback callbackObj) Helper static method to add failed auth callback listenersstatic 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
Flush all WsClient caches for all interfacesstatic IWSCacheManager
Get a reference to the Cache Manager object.static WSClientConfig
Helper static method to retrieve the WSClientConfig configuration objectstatic IWSProxyFactory
getFactory
(Class<?> clazz) Returns the appropriateIWSProxyFactory
for this interface class, or the default implementationstatic IWSProxyFactory
getFactory
(Class<?> clazz, String clientID) Returns the appropriateIWSProxyFactory
for this interface class and client ID, or the default implementationprotected static String
getFactoryMapKey
(Class<?> clazz, String clientID) static List<IFailedAuthCallback>
Get the list of registered Auth failure callback objectsstatic Object
A convenience method that first obtains the defaultIWSProxyFactory
and and returns an instance of aIWSClientProxy
static Object
A convenience method that first obtains the defaultIWSProxyFactory
and and returns an instance of aIWSClientProxy
static Object
getProxy
(Class<?> clazz, String wsdlURL, String[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result caching and session re-usestatic Object
getProxy
(Class<?> clazz, String wsdlURL, String[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession, int socketTimeout, AuthCredentials authCredentials) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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[] mapURLs, String endPointURL, boolean useCache, boolean reuseSession, AuthCredentials authCredentials) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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
A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result cachingstatic Object
getProxy
(Class<?> clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result caching and session re-usestatic Object
getProxy
(Class<?> clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession, int socketTimeout, AuthCredentials authCredentials) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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, boolean reuseSession, AuthCredentials authCredentials) A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, allows the enable/disable of result caching and session re-use, as well as supplying credentials that override those of the proxy factory.static IWSClientSessionManager
Get a reference to the Session Manager object.static void
init
(WSClientConfig clientConfig) Initialize the default WSClient instance with the supplied configurationprotected static WSClient
instance()
Get the default static instance of WSClientstatic boolean
isInit()
Has the default instance of WSClient been initializedstatic void
registerFactory
(Class<?> clazz, IWSProxyFactory proxyFactory) Registers a new IWSProxyFactory for the specified classstatic void
registerFactory
(Class<?> clazz, String clientID, IWSProxyFactory proxyFactory) Registers a new IWSProxyFactory for the specified classstatic void
removeFailedAuthCallback
(IFailedAuthCallback callbackObj) Helper static method to remove failed auth callback listenersstatic 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 anIWSProxyFactory
static void
unRegisterFactory
(Class<?> clazz, String clientID) Unregisters anIWSProxyFactory
-
Field Details
-
logger
public static org.slf4j.Logger logger -
WSCLIENT_MOD
Module name of WSClient for logging purposes
-
-
Method Details
-
init
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 defaultIWSProxyFactory
and and returns an instance of aIWSClientProxy
- Parameters:
clazz
- the web service interface to proxy with WSClientwsdlURL
- the URL of the web service WSDL file as a stringendPointURL
- 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:
-
getProxy
public static Object getProxy(Class<?> clazz, String wsdlURL, String[] mapURLs, String endPointURL) throws WSClientException A convenience method that first obtains the defaultIWSProxyFactory
and and returns an instance of aIWSClientProxy
- Parameters:
clazz
- the web service interface to proxy with WSClientwsdlURL
- the URL of the web service WSDL file as a stringmapURLs
- an array of web service .map file URLsendPointURL
- 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:
-
getProxy
public static Object getProxy(Class<?> clazz, String wsdlURL, String endPointURL, boolean useCache) throws WSClientException A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result caching- Parameters:
clazz
- the web service interface to proxy with WSClientwsdlURL
- the URL of the web service WSDL file as a stringendPointURL
- the web service endpoint URL as a stringuseCache
- 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:
-
getProxy
public static Object getProxy(Class<?> clazz, String wsdlURL, String endPointURL, boolean useCache, boolean reuseSession) throws WSClientException A convenience method that first obtains theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result caching and session re-use- Parameters:
clazz
- the web service interface to proxy with WSClientwsdlURL
- the URL of the web service WSDL file as a stringendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
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 theIWSProxyFactory
and and returns an instance of aIWSClientProxy
and allows the enable/disable of result caching and session re-use- Parameters:
clazz
- the web service interface to proxy with WSClientwsdlURL
- the URL of the web service WSDL file as a stringmapURLs
- an array of web service .map file URLsendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
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 theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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 WSClientwsdlURL
- the URL of the web service WSDL file as a stringendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
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 theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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 WSClientwsdlURL
- the URL of the web service WSDL file as a stringmapURLs
- an array of web service .map file URLsendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
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 theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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 WSClientwsdlURL
- the URL of the web service WSDL file as a stringendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
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 theIWSProxyFactory
and and returns an instance of aIWSClientProxy
, 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 WSClientwsdlURL
- the URL of the web service WSDL file as a stringmapURLs
- an array of web service .map file URLsendPointURL
- the web service endpoint URL as a stringuseCache
- true to enable caching of the web service resultsreuseSession
- 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:
-
instance
Get the default static instance of WSClient- Returns:
- the default static instace of WSClient
-
registerFactory
Registers a new IWSProxyFactory for the specified class- Parameters:
clazz
- the param used in calls togetFactory(Class)
proxyFactory
- the custom implemenation ofIWSProxyFactory
-
registerFactory
Registers a new IWSProxyFactory for the specified class- Parameters:
clazz
- the param used in calls togetFactory(Class)
clientID
- clientID - used to separate factories by client if desiredproxyFactory
- the custom implemenation ofIWSProxyFactory
-
_registerFactory
Internal instance method. Registers a new IWSProxyFactory for the specified class- Parameters:
clazz
- the param used in calls togetFactory(Class)
clientID
- the param used to seperate factory caches by client (optionproxyFactory
- the custom implemenation ofIWSProxyFactory
-
_unRegisterFactory
Internal instance method. Unregisters anIWSProxyFactory
- Parameters:
clazz
- the param used in calls togetFactory(Class)
-
unRegisterFactory
Unregisters anIWSProxyFactory
- Parameters:
clazz
-
-
unRegisterFactory
Unregisters anIWSProxyFactory
- Parameters:
clazz
- the interface class to unregisterclientID
- a client ID identifier to allow separate client caches
-
_getFactory
Internal instance method. Returns the appropriateIWSProxyFactory
for this interface class, or the default implementation- Parameters:
clazz
- The web service interface class to proxyclazz
- a string ID to separate proxy caches- Returns:
- an instance of IWSProxyFactory associated with the specified interface
-
getFactory
Returns the appropriateIWSProxyFactory
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
Returns the appropriateIWSProxyFactory
for this interface class and client ID, or the default implementation- Parameters:
clazz
- The web service interface class to proxyclientID
- - a string identifier to allow separation of proxy factories by client- Returns:
- an instance of IWSProxyFactory associated with the specified interface
-
_getSessionManager
Internal instance method. Get a reference to the Session Manager object.- Returns:
- instance of
IWSClientSessionManager
-
getSessionManager
Get a reference to the Session Manager object.- Returns:
- instance of
IWSClientSessionManager
-
_getCacheManager
Internal instance method.- Returns:
- instance of
IWSCacheManager
-
getCacheManager
Get a reference to the Cache Manager object.- Returns:
- instance of
IWSCacheManager
-
addLogListener
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 ofILogListener
-
removeLogListener
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 ofILogListener
to unregister
-
_getClientConfig
Get the current client configuration object- Returns:
-
getClientConfig
Helper static method to retrieve the WSClientConfig configuration object- Returns:
- instance of
WSClientConfig
used to configure this instance of WSClient
-
addFailedAuthCallback
Helper static method to add failed auth callback listeners- Parameters:
callbackObj
-IFailedAuthCallback
instance to register- See Also:
-
_addFailedAuthCallback
Add a callback listener to be invoked when an auth failure occurs- Parameters:
callbackObj
-IFailedAuthCallback
instance to register- See Also:
-
removeFailedAuthCallback
Helper static method to remove failed auth callback listeners- Parameters:
callbackObj
-IFailedAuthCallback
instance to unregister- See Also:
-
_removeFailedAuthCallback
Remove a previously registered auth failure callback listener- Parameters:
callbackObj
-IFailedAuthCallback
instance to unregister
-
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
-