@ -18,8 +18,11 @@ package org.springframework.remoting.jaxws;
@@ -18,8 +18,11 @@ package org.springframework.remoting.jaxws;
import java.lang.reflect.InvocationTargetException ;
import java.lang.reflect.Method ;
import java.net.MalformedURLException ;
import java.net.URL ;
import java.util.HashMap ;
import java.util.Map ;
import javax.jws.WebService ;
import javax.xml.namespace.QName ;
import javax.xml.ws.BindingProvider ;
import javax.xml.ws.ProtocolException ;
@ -41,6 +44,7 @@ import org.springframework.remoting.RemoteLookupFailureException;
@@ -41,6 +44,7 @@ import org.springframework.remoting.RemoteLookupFailureException;
import org.springframework.remoting.RemoteProxyFailureException ;
import org.springframework.util.Assert ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.StringUtils ;
/ * *
* { @link org . aopalliance . intercept . MethodInterceptor } for accessing a specific
@ -317,9 +321,14 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
@@ -317,9 +321,14 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
* Initialize the JAX - WS port for this interceptor .
* /
public void prepare ( ) {
if ( getServiceInterface ( ) = = null ) {
Class < ? > ifc = getServiceInterface ( ) ;
if ( ifc = = null ) {
throw new IllegalArgumentException ( "Property 'serviceInterface' is required" ) ;
}
WebService ann = ifc . getAnnotation ( WebService . class ) ;
if ( ann ! = null ) {
applyDefaultsFromAnnotation ( ann ) ;
}
Service serviceToUse = getJaxWsService ( ) ;
if ( serviceToUse = = null ) {
serviceToUse = createJaxWsService ( ) ;
@ -330,6 +339,52 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
@@ -330,6 +339,52 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
this . portStub = stub ;
}
/ * *
* Initialize this client interceptor ' s properties from the given WebService annotation ,
* if necessary and possible ( i . e . if "wsdlDocumentUrl" , "namespaceUri" , "serviceName"
* and "portName" haven ' t been set but corresponding values are declared at the
* annotation level of the specified service interface ) .
* @param ann the WebService annotation found on the specified service interface
* /
protected void applyDefaultsFromAnnotation ( WebService ann ) {
if ( getWsdlDocumentUrl ( ) = = null ) {
String wsdl = ann . wsdlLocation ( ) ;
if ( StringUtils . hasText ( wsdl ) ) {
try {
setWsdlDocumentUrl ( new URL ( wsdl ) ) ;
}
catch ( MalformedURLException ex ) {
throw new IllegalStateException (
"Encountered invalid @Service wsdlLocation value [" + wsdl + "]" , ex ) ;
}
}
}
if ( getNamespaceUri ( ) = = null ) {
String ns = ann . targetNamespace ( ) ;
if ( StringUtils . hasText ( ns ) ) {
setNamespaceUri ( ns ) ;
}
}
if ( getServiceName ( ) = = null ) {
String sn = ann . serviceName ( ) ;
if ( StringUtils . hasText ( sn ) ) {
setServiceName ( sn ) ;
}
}
if ( getPortName ( ) = = null ) {
String pn = ann . portName ( ) ;
if ( StringUtils . hasText ( pn ) ) {
setPortName ( pn ) ;
}
else {
String nm = ann . name ( ) ;
if ( StringUtils . hasText ( nm ) ) {
setPortName ( nm ) ;
}
}
}
}
/ * *
* Return whether this client interceptor has already been prepared ,
* i . e . has already looked up the JAX - WS service and port .
@ -478,7 +533,6 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
@@ -478,7 +533,6 @@ public class JaxWsPortClientInterceptor extends LocalJaxWsServiceFactory
}
}
/ * *
* Inner class in order to avoid a hard - coded JAX - WS 2 . 1 dependency .
* JAX - WS 2 . 0 , as used in Java EE 5 , didn ' t have WebServiceFeatures yet . . .