Class WSClient

java.lang.Object
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 Details

    • logger

      public static org.slf4j.Logger logger
    • WSCLIENT_MOD

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

    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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 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 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 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 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:
    • _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:
    • removeFailedAuthCallback

      public static void removeFailedAuthCallback(IFailedAuthCallback callbackObj)
      Helper static method to remove failed auth callback listeners
      Parameters:
      callbackObj - IFailedAuthCallback instance to unregister
      See Also:
    • _removeFailedAuthCallback

      public void _removeFailedAuthCallback(IFailedAuthCallback callbackObj)
      Remove a previously registered auth failure callback listener
      Parameters:
      callbackObj - IFailedAuthCallback instance to unregister
    • getFailedAuthListeners

      public static List<IFailedAuthCallback> 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)