Class WSClientDynamicProxy
java.lang.Object
com.webmethods.caf.wsclient.proxy.impl.WSClientDynamicProxy
- All Implemented Interfaces:
IWSClientProxy
,InvocationHandler
Dynamic proxy that implements the
IWSClientProxy
interface and proxies requests for a
web service interface, providing services such as session managment via a IWSClientSession
instance,
as well as web service result caching via a IWSCacheManager
.
The web service request is handled by the underlying Glue SOAP stack
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthCredentials
protected int
protected String
protected List<IFailedAuthCallback>
protected String
protected IWSProxyFactory
protected boolean
protected boolean
protected Class<?>
protected String
static final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionWSClientDynamicProxy
(IWSProxyFactory proxyFactory, Class<?> clazz, String wsdlURL, String endPoint, boolean useCache, boolean reuseSession, int clientSocketReadTimeout, AuthCredentials authCredentials) Primary constructor for creating a new proxy instance for a web service interface stub NOTE: normally this constructor is not called directly, instead a new proxy is obtained via the proxy factory {@link IWSProxyFactory.getProxy()} -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFailedAuthCallback
(IFailedAuthCallback callbackObj) Register aIFailedAuthCallback
listener to be invoked when an authentication failure occurs when invoking a web servicevoid
Flush the cache web service results cache associated with this proxyGet theAuthCredentials
used by this proxy to authenticate web service request.protected Throwable
helper method to unravel InvocationException and WrappedExceptionsprotected Object
getBinding
(electric.glue.context.ProxyContext context) int
Get the socket timeout.protected Throwable
getCompatibleException
(Method method, Throwable t) Translate an exception into a Throwable that is explicitly declared in the the method's throws clause, or wrapped as a RuntimeException (this avoids a UndeclaredThrowableException)Get the endpoint that this web service proxy will invokeGet the list of all registeredIFailedAuthCallback
listenersGet the host partion of theIWSClientProxy.getEndPointURL()
}The factory that instantiated this proxyboolean
Whether to attempt to recycle an existingIWSClientSession
when invoking a web serviceboolean
Whether invocations will check with the CacheManagerClass<?>
Get the portType class that this IWSClientProxy instance is proxyingThe WSDL url for this proxyInvoke a web service method.invokeMethod
(IWSClientSession session, Method method, Object[] args) Directly invoke a web service method.protected boolean
isNonRetryableException
(Throwable throwable) Determine if an exception is fatal (connection, transport, or other non-retry types of errors)void
removeFailedAuthCallback
(IFailedAuthCallback callbackObj) Remove a specificIFailedAuthCallback
object from the list of listenersvoid
setAuthCredentials
(AuthCredentials authCredentials) void
setHostURL
(String hostURL) void
setReuseSession
(boolean reuseCache) Specify whether to attempt to recycle an existingIWSClientSession
when invoking a web servicevoid
setUseCache
(boolean useCache) Set option for the cache manager to cache web service resultsprotected Throwable
wrapWsClientException
(Throwable throwable) Wrap the exception if with WsClientException with additional error text (if appropriate)
-
Field Details
-
m_proxyFactory
-
m_webServiceClass
-
m_wsdlURL
-
m_endPointURL
-
m_hostURL
-
m_useCache
protected boolean m_useCache -
m_reuseSession
protected boolean m_reuseSession -
m_clientSocketReadTimeout
protected int m_clientSocketReadTimeout -
m_authCredentials
-
m_failedAuthCallbacks
-
REMOVE_WSDL_FROM_GLUE_CACHE
public static final boolean REMOVE_WSDL_FROM_GLUE_CACHE
-
-
Constructor Details
-
WSClientDynamicProxy
public WSClientDynamicProxy(IWSProxyFactory proxyFactory, Class<?> clazz, String wsdlURL, String endPoint, boolean useCache, boolean reuseSession, int clientSocketReadTimeout, AuthCredentials authCredentials) Primary constructor for creating a new proxy instance for a web service interface stub NOTE: normally this constructor is not called directly, instead a new proxy is obtained via the proxy factory {@link IWSProxyFactory.getProxy()}- Parameters:
proxyFactory
-IWSProxyFactory
the proxy factoryclazz
- web service interface to proxywsdlURL
- URL of the web service WSDL fileendPoint
- The endpoint URL of the web serviceuseCache
- enable/disable web service result caching for this proxyreuseSession
- true to enable/disable session reuse for this proxyclientSocketReadTimeout
- the web service timeout in millisecondsauthCredentials
-AuthCredentials
to use when authenticating the web service request. If null, theAuthCredentials
of the WSProxyFactory will be used.
-
WSClientDynamicProxy
public WSClientDynamicProxy()
-
-
Method Details
-
invokeMethod
Directly invoke a web service method. Note: the normal use case is to invoke theinvoke()
method, which includes authentication retries and result caching- Parameters:
session
-IWSClientSession
instance to invoke the web service throughmethod
- theMethod
on the web service interface to invokeargs
- the web service method arguments as an Object[]- Returns:
- the return value of the web service request
- Throws:
Throwable
-
invoke
Invoke a web service method. When any method on the web service interface is invoked, it is chained this this invoke() method (that is the nature of a dynamic proxy, @see InvocationHandler)- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
-IWSClientSession
instance to invoke the web service throughmethod
- theMethod
on the web service interface to invokeargs
- the web service method arguments as an Object[]- Returns:
- the return value of the web service request
- Throws:
Throwable
-
getProxyFactory
Description copied from interface:IWSClientProxy
The factory that instantiated this proxy- Specified by:
getProxyFactory
in interfaceIWSClientProxy
- Returns:
- the
IWSProxyFactory
that created this proxy instance
-
getEndPointURL
Description copied from interface:IWSClientProxy
Get the endpoint that this web service proxy will invoke- Specified by:
getEndPointURL
in interfaceIWSClientProxy
- Returns:
- the endpoint URL as string
-
getHostURL
Description copied from interface:IWSClientProxy
Get the host partion of theIWSClientProxy.getEndPointURL()
}- Specified by:
getHostURL
in interfaceIWSClientProxy
- Returns:
- the host name as string
-
getWsdlURL
Description copied from interface:IWSClientProxy
The WSDL url for this proxy- Specified by:
getWsdlURL
in interfaceIWSClientProxy
- Returns:
- the WSDL URL as a string
-
getUseCache
public boolean getUseCache()Description copied from interface:IWSClientProxy
Whether invocations will check with the CacheManager- Specified by:
getUseCache
in interfaceIWSClientProxy
- Returns:
- true if the cache manager is configured to use caching
-
setUseCache
public void setUseCache(boolean useCache) Description copied from interface:IWSClientProxy
Set option for the cache manager to cache web service results- Specified by:
setUseCache
in interfaceIWSClientProxy
- Parameters:
useCache
- true to enable caching, false to disable caching
-
getReuseSession
public boolean getReuseSession()Description copied from interface:IWSClientProxy
Whether to attempt to recycle an existingIWSClientSession
when invoking a web service- Specified by:
getReuseSession
in interfaceIWSClientProxy
- Returns:
- boolean true if session reuse is enabled, false if session reuse is disabled
-
setReuseSession
public void setReuseSession(boolean reuseCache) Description copied from interface:IWSClientProxy
Specify whether to attempt to recycle an existingIWSClientSession
when invoking a web service- Specified by:
setReuseSession
in interfaceIWSClientProxy
- Parameters:
reuseCache
- true to enable session reuse, false to create a new session on each service invocation
-
getAuthCredentials
Description copied from interface:IWSClientProxy
Get theAuthCredentials
used by this proxy to authenticate web service request. Specifying null credentials will use global credentials set on the {@link @WSClient} instance.- Specified by:
getAuthCredentials
in interfaceIWSClientProxy
- Returns:
- the
AuthCredentials
for this proxy
-
getWebServiceClass
Description copied from interface:IWSClientProxy
Get the portType class that this IWSClientProxy instance is proxying- Specified by:
getWebServiceClass
in interfaceIWSClientProxy
- Returns:
- the portType as Class
-
getClientSocketReadTimeout
public int getClientSocketReadTimeout()Description copied from interface:IWSClientProxy
Get the socket timeout. This is the number of milliseconds the web service request will wait before it gives up waiting for a response from the web service provider.- Specified by:
getClientSocketReadTimeout
in interfaceIWSClientProxy
- Returns:
- the socket timeout value in milliseconds
-
getBinding
-
addFailedAuthCallback
Description copied from interface:IWSClientProxy
Register aIFailedAuthCallback
listener to be invoked when an authentication failure occurs when invoking a web service- Specified by:
addFailedAuthCallback
in interfaceIWSClientProxy
- Parameters:
callbackObj
- - theIFailedAuthCallback
object instance
-
removeFailedAuthCallback
Description copied from interface:IWSClientProxy
Remove a specificIFailedAuthCallback
object from the list of listeners- Specified by:
removeFailedAuthCallback
in interfaceIWSClientProxy
- Parameters:
callbackObj
- - the IFailedAuthCallback object instance to remove
-
getFailedAuthListeners
Description copied from interface:IWSClientProxy
Get the list of all registeredIFailedAuthCallback
listeners- Specified by:
getFailedAuthListeners
in interfaceIWSClientProxy
- Returns:
- a List of
IFailedAuthCallback
instances
-
getInternalMethods
-
getBaseException
helper method to unravel InvocationException and WrappedExceptions -
getCompatibleException
Translate an exception into a Throwable that is explicitly declared in the the method's throws clause, or wrapped as a RuntimeException (this avoids a UndeclaredThrowableException)- Parameters:
method
- - the invoked methodt
- - the exception thrown by the method- Returns:
- a Throwable that will not result in a UndeclaredThrowableException NOTE: this code is lifted from Glue's Proxy.java
-
flushCache
public void flushCache()Description copied from interface:IWSClientProxy
Flush the cache web service results cache associated with this proxy- Specified by:
flushCache
in interfaceIWSClientProxy
-
wrapWsClientException
Wrap the exception if with WsClientException with additional error text (if appropriate)- Parameters:
throwable
- exception thrown by the web service invocation- Returns:
- a new WSClientException wrapping the web service exception
-
isNonRetryableException
Determine if an exception is fatal (connection, transport, or other non-retry types of errors)- Parameters:
throwable
- the Exception to examine- Returns:
- true if the error is fatal and we shouldn't retry the invocation
-
setHostURL
-
setAuthCredentials
-