public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory implements BeanClassLoaderAware, InitializingBean
org.aopalliance.intercept.MethodInterceptor
for accessing a specific
port of a JAX-WS service. Compatible with JAX-WS 2.1 and 2.2.
Uses either LocalJaxWsServiceFactory
's facilities underneath,
or takes an explicit reference to an existing JAX-WS Service instance
(e.g. obtained via JndiObjectFactoryBean
).
setPortName(java.lang.String)
,
setServiceInterface(java.lang.Class<?>)
,
Service.getPort(javax.xml.namespace.QName, java.lang.Class<T>)
,
RemoteAccessException
,
JndiObjectFactoryBean
Modifier and Type | Field and Description |
---|---|
private java.lang.ClassLoader |
beanClassLoader |
private java.util.Map<java.lang.String,java.lang.Object> |
customProperties |
private java.lang.String |
endpointAddress |
private javax.xml.ws.Service |
jaxWsService |
private boolean |
lookupServiceOnStartup |
private boolean |
maintainSession |
private java.lang.String |
password |
private javax.xml.ws.WebServiceFeature[] |
portFeatures |
private java.lang.String |
portName |
private javax.xml.namespace.QName |
portQName |
private java.lang.Object |
portStub |
private java.lang.Object |
preparationMonitor |
private java.lang.Class<?> |
serviceInterface |
private java.lang.String |
soapActionUri |
private java.lang.String |
username |
private boolean |
useSoapAction |
private java.lang.Object[] |
webServiceFeatures |
Constructor and Description |
---|
JaxWsPortClientInterceptor() |
Modifier and Type | Method and Description |
---|---|
void |
addCustomProperty(java.lang.String name,
java.lang.Object value)
Add a custom property to this JAX-WS BindingProvider.
|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected void |
applyDefaultsFromAnnotation(javax.jws.WebService ann)
Initialize this client interceptor's properties from the given WebService annotation,
if necessary and possible (i.e.
|
private javax.xml.ws.WebServiceFeature |
convertWebServiceFeature(java.lang.Object feature)
Convert the given feature specification object to a WebServiceFeature instance
|
protected java.lang.Object |
doInvoke(MethodInvocation invocation)
Perform a JAX-WS service invocation based on the given method invocation.
|
protected java.lang.Object |
doInvoke(MethodInvocation invocation,
java.lang.Object portStub)
Perform a JAX-WS service invocation on the given port stub.
|
protected java.lang.ClassLoader |
getBeanClassLoader()
Return the bean ClassLoader to use for this interceptor.
|
java.util.Map<java.lang.String,java.lang.Object> |
getCustomProperties()
Allow Map access to the custom properties to be set on the stub,
with the option to add or override specific entries.
|
java.lang.String |
getEndpointAddress()
Return the endpoint address to specify on the stub.
|
javax.xml.ws.Service |
getJaxWsService()
Return a reference to an existing JAX-WS Service instance, if any.
|
java.lang.String |
getPassword()
Return the password to specify on the stub.
|
java.lang.String |
getPortName()
Return the name of the port.
|
protected javax.xml.namespace.QName |
getPortQName()
Return the prepared QName for the port.
|
protected java.lang.Object |
getPortStub()
Return the underlying JAX-WS port stub that this interceptor delegates to
for each method invocation on the proxy.
|
protected java.lang.Object |
getPortStub(javax.xml.ws.Service service,
javax.xml.namespace.QName portQName)
Obtain the port stub from the given JAX-WS Service.
|
java.lang.Class<?> |
getServiceInterface()
Return the interface of the service that this factory should create a proxy for.
|
java.lang.String |
getSoapActionUri()
Return the SOAP action URI to specify on the stub.
|
java.lang.String |
getUsername()
Return the username to specify on the stub.
|
java.lang.Object |
invoke(MethodInvocation invocation) |
boolean |
isMaintainSession()
Return the "session.maintain" flag to specify on the stub.
|
protected boolean |
isPrepared()
Return whether this client interceptor has already been prepared,
i.e.
|
boolean |
isUseSoapAction()
Return the "soapaction.use" flag to specify on the stub.
|
void |
prepare()
Initialize the JAX-WS port for this interceptor.
|
protected void |
preparePortStub(java.lang.Object stub)
Prepare the given JAX-WS port stub, applying properties to it.
|
void |
setBeanClassLoader(java.lang.ClassLoader classLoader)
Set the bean ClassLoader to use for this interceptor:
for resolving WebServiceFeature class names as specified through
setWebServiceFeatures(java.lang.Object[]) , and also for building a client
proxy in the JaxWsPortProxyFactoryBean subclass. |
void |
setCustomProperties(java.util.Map<java.lang.String,java.lang.Object> customProperties)
Set custom properties to be set on the stub.
|
void |
setEndpointAddress(java.lang.String endpointAddress)
Set the endpoint address to specify on the stub.
|
void |
setJaxWsService(javax.xml.ws.Service jaxWsService)
Set a reference to an existing JAX-WS Service instance,
for example obtained via
JndiObjectFactoryBean . |
void |
setLookupServiceOnStartup(boolean lookupServiceOnStartup)
Set whether to look up the JAX-WS service on startup.
|
void |
setMaintainSession(boolean maintainSession)
Set the "session.maintain" flag to specify on the stub.
|
void |
setPassword(java.lang.String password)
Set the password to specify on the stub.
|
void |
setPortFeatures(javax.xml.ws.WebServiceFeature... features)
Specify WebServiceFeature objects (e.g.
|
void |
setPortName(java.lang.String portName)
Set the name of the port.
|
void |
setServiceInterface(java.lang.Class<?> serviceInterface)
Set the interface of the service that this factory should create a proxy for.
|
void |
setSoapActionUri(java.lang.String soapActionUri)
Set the SOAP action URI to specify on the stub.
|
void |
setUsername(java.lang.String username)
Set the username to specify on the stub.
|
void |
setUseSoapAction(boolean useSoapAction)
Set the "soapaction.use" flag to specify on the stub.
|
void |
setWebServiceFeatures(java.lang.Object[] webServiceFeatures)
Deprecated.
as of Spring 4.0, in favor of the differentiated
"serviceFeatures" and
"portFeatures" properties |
createJaxWsService, getNamespaceUri, getQName, getServiceName, getWsdlDocumentUrl, setExecutor, setHandlerResolver, setNamespaceUri, setServiceFeatures, setServiceName, setWsdlDocumentResource, setWsdlDocumentUrl
private javax.xml.ws.Service jaxWsService
private java.lang.String portName
private java.lang.String username
private java.lang.String password
private java.lang.String endpointAddress
private boolean maintainSession
private boolean useSoapAction
private java.lang.String soapActionUri
private java.util.Map<java.lang.String,java.lang.Object> customProperties
private javax.xml.ws.WebServiceFeature[] portFeatures
private java.lang.Object[] webServiceFeatures
private java.lang.Class<?> serviceInterface
private boolean lookupServiceOnStartup
private java.lang.ClassLoader beanClassLoader
private javax.xml.namespace.QName portQName
private java.lang.Object portStub
private final java.lang.Object preparationMonitor
public void setJaxWsService(javax.xml.ws.Service jaxWsService)
JndiObjectFactoryBean
.
If not set, LocalJaxWsServiceFactory
's properties have to be specified.public javax.xml.ws.Service getJaxWsService()
public void setPortName(java.lang.String portName)
public java.lang.String getPortName()
public void setUsername(java.lang.String username)
BindingProvider.USERNAME_PROPERTY
public java.lang.String getUsername()
public void setPassword(java.lang.String password)
BindingProvider.PASSWORD_PROPERTY
public java.lang.String getPassword()
public void setEndpointAddress(java.lang.String endpointAddress)
BindingProvider.ENDPOINT_ADDRESS_PROPERTY
public java.lang.String getEndpointAddress()
public void setMaintainSession(boolean maintainSession)
BindingProvider.SESSION_MAINTAIN_PROPERTY
public boolean isMaintainSession()
public void setUseSoapAction(boolean useSoapAction)
BindingProvider.SOAPACTION_USE_PROPERTY
public boolean isUseSoapAction()
public void setSoapActionUri(java.lang.String soapActionUri)
BindingProvider.SOAPACTION_URI_PROPERTY
public java.lang.String getSoapActionUri()
public void setCustomProperties(java.util.Map<java.lang.String,java.lang.Object> customProperties)
Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.
BindingProvider.getRequestContext()
public java.util.Map<java.lang.String,java.lang.Object> getCustomProperties()
Useful for specifying entries directly, for example via "customProperties[myKey]". This is particularly useful for adding or overriding entries in child bean definitions.
public void addCustomProperty(java.lang.String name, java.lang.Object value)
name
- the name of the attribute to exposevalue
- the attribute value to exposeBindingProvider.getRequestContext()
public void setPortFeatures(javax.xml.ws.WebServiceFeature... features)
Note: This mechanism requires a fully JAX-WS 2.1 compliant provider.
Service.getPort(Class, javax.xml.ws.WebServiceFeature...)
,
LocalJaxWsServiceFactory.setServiceFeatures(javax.xml.ws.WebServiceFeature...)
@Deprecated public void setWebServiceFeatures(java.lang.Object[] webServiceFeatures)
"serviceFeatures"
and
"portFeatures"
propertiesWebServiceFeature
objects,
WebServiceFeature Class references, or WebServiceFeature class names.
As of Spring 4.0, this is effectively just an alternative way of
specifying "portFeatures"
. Do not specify
both properties at the same time; prefer "portFeatures" moving forward.
public void setServiceInterface(java.lang.Class<?> serviceInterface)
public java.lang.Class<?> getServiceInterface()
public void setLookupServiceOnStartup(boolean lookupServiceOnStartup)
Default is "true". Turn this flag off to allow for late start of the target server. In this case, the JAX-WS service will be lazily fetched on first access.
public void setBeanClassLoader(java.lang.ClassLoader classLoader)
setWebServiceFeatures(java.lang.Object[])
, and also for building a client
proxy in the JaxWsPortProxyFactoryBean
subclass.setBeanClassLoader
in interface BeanClassLoaderAware
classLoader
- the owning class loader; may be null
in
which case a default ClassLoader
must be used, for example
the ClassLoader
obtained via
ClassUtils.getDefaultClassLoader()
protected java.lang.ClassLoader getBeanClassLoader()
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public void prepare()
protected void applyDefaultsFromAnnotation(javax.jws.WebService ann)
ann
- the WebService annotation found on the specified service interfaceprotected boolean isPrepared()
protected final javax.xml.namespace.QName getPortQName()
protected java.lang.Object getPortStub(javax.xml.ws.Service service, javax.xml.namespace.QName portQName)
service
- the Service object to obtain the port fromportQName
- the name of the desired port, if specifiedService.getPort(...)
private javax.xml.ws.WebServiceFeature convertWebServiceFeature(java.lang.Object feature)
feature
- the feature specification object, as passed into the
"webServiceFeatures"
bean propertynull
)protected void preparePortStub(java.lang.Object stub)
prepare()
.stub
- the current JAX-WS port stubsetUsername(java.lang.String)
,
setPassword(java.lang.String)
,
setEndpointAddress(java.lang.String)
,
setMaintainSession(boolean)
,
setCustomProperties(java.util.Map<java.lang.String, java.lang.Object>)
protected java.lang.Object getPortStub()
public java.lang.Object invoke(MethodInvocation invocation) throws java.lang.Throwable
java.lang.Throwable
protected java.lang.Object doInvoke(MethodInvocation invocation) throws java.lang.Throwable
invocation
- the AOP method invocationjava.lang.Throwable
- in case of invocation failuregetPortStub()
,
#doInvoke(org.aopalliance.intercept.MethodInvocation, Object)
protected java.lang.Object doInvoke(MethodInvocation invocation, java.lang.Object portStub) throws java.lang.Throwable
invocation
- the AOP method invocationportStub
- the RMI port stub to invokejava.lang.Throwable
- in case of invocation failuregetPortStub()