You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ng...@apache.org on 2008/03/24 06:46:34 UTC
svn commit: r640319 - in /webservices/axis2/trunk/java/modules/metadata:
src/org/apache/axis2/jaxws/description/builder/converter/
src/org/apache/axis2/jaxws/description/impl/
src/org/apache/axis2/jaxws/description/validator/
test/org/apache/axis2/jaxw...
Author: ngallardo
Date: Sun Mar 23 22:46:34 2008
New Revision: 640319
URL: http://svn.apache.org/viewvc?rev=640319&view=rev
Log:
AXIS2-3449
Additional @RespectBinding feature enablement and validation.
Modified:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/feature/RespectBindingFeatureTests.java
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java?rev=640319&r1=640318&r2=640319&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/converter/JavaClassToDBCConverter.java Sun Mar 23 22:46:34 2008
@@ -63,8 +63,6 @@
static {
annotationProcessors = new HashMap<Class, Object>();
-
-
}
public JavaClassToDBCConverter(Class serviceClass) {
@@ -83,6 +81,10 @@
* @return - <code>DescriptionBuilderComposite</code>
*/
public HashMap<String, DescriptionBuilderComposite> produceDBC() {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating DescriptionBuilderComposite map from Java Class.");
+ }
+
HashMap<String, DescriptionBuilderComposite> dbcMap = new HashMap<String,
DescriptionBuilderComposite>();
for (int i = 0; i < classes.size(); i++) {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=640319&r1=640318&r2=640319&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Sun Mar 23 22:46:34 2008
@@ -173,7 +173,7 @@
javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING;
// ANNOTATION: @RespectBinding
- private boolean respectBinding = true;
+ private Boolean respectBinding = false;
private List<CustomAnnotationInstance> customAnnotations;
@@ -1475,7 +1475,7 @@
}
// ===========================================
- // ANNOTATION: MTOM
+ // ANNOTATION: RespectBinding
// ===========================================
public boolean respectBinding() {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java?rev=640319&r1=640318&r2=640319&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java Sun Mar 23 22:46:34 2008
@@ -59,6 +59,10 @@
if (!validateWSDLBindingType()) {
return INVALID;
}
+
+ if (!validateRespectBinding()) {
+ return INVALID;
+ }
}
if (!validateEndpointInterface()) {
@@ -180,6 +184,29 @@
}
}
return VALID;
+ }
+
+ /*
+ * If the @RespectBinding annotation is present, then we must also have a WSDL
+ */
+ private boolean validateRespectBinding() {
+ // If a WSDL with a valid <wsdl:port> was present, then the WSDL is considered
+ // fully specified. Without that, the @RespectBinding annotation is invalid.
+ if (endpointDesc.respectBinding()) {
+ String wsdlLocation = null;
+ if (!endpointDesc.isProviderBased()) {
+ wsdlLocation = endpointDescJava.getAnnoWebServiceWSDLLocation();
+ }
+ else {
+ wsdlLocation = endpointDescJava.getAnnoWebServiceProvider().wsdlLocation();
+ }
+
+ if (wsdlLocation == null || wsdlLocation.length() == 0) {
+ addValidationFailure(this, "Annotation @RespectBinding requires that a WSDL file be specified.");
+ return Validator.INVALID;
+ }
+ }
+ return Validator.VALID;
}
private static String bindingHumanReadableDescription(String ns) {
Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/feature/RespectBindingFeatureTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/feature/RespectBindingFeatureTests.java?rev=640319&r1=640318&r2=640319&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/feature/RespectBindingFeatureTests.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/feature/RespectBindingFeatureTests.java Sun Mar 23 22:46:34 2008
@@ -23,51 +23,133 @@
import org.apache.axis2.jaxws.description.DescriptionFactory;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter;
+import org.apache.axis2.jaxws.util.WSDL4JWrapper;
import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.ws.RespectBinding;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class RespectBindingFeatureTests extends TestCase {
private static final String ns = "http://jaxws.axis2.apache.org/metadata/feature/respectbinding";
+ private static final String serviceName = "EchoMessageService";
+ private static final String portTypeName = "EchoMessagePortType";
+
+
private static final String plainServicePortName = "PlainServicePort";
private static final String disabledServicePortName = "DisabledServicePort";
+ private static final String defaultServicePortName = "DefaultServicePort";
+
+ private static final String wsdlLocation = "test-resources/wsdl/RespectBinding.wsdl";
- public void testDefaultConfig() {
- ServiceDescription sd = DescriptionFactory.createServiceDescription(PlainService.class);
+ /*
+ * RespectBinding should be disabled because a WSDL file was not included.
+ */
+
+ public void testPlain() throws Exception {
+ JavaClassToDBCConverter converter = new JavaClassToDBCConverter(PlainService.class);
+ HashMap<String, DescriptionBuilderComposite> map = converter.produceDBC();
+
+ DescriptionBuilderComposite composite = map.get(PlainService.class.getName());
+
+ URL wsdlUrl = new URL("file:./" + wsdlLocation);
+ WSDL4JWrapper wrapper = new WSDL4JWrapper(wsdlUrl, false, 0);
+
+ composite.setwsdlURL(wsdlUrl);
+ composite.setWsdlDefinition(wrapper.getDefinition());
+
+ List<ServiceDescription> sdList = null;
+ try {
+ sdList = DescriptionFactory.createServiceDescriptionFromDBCMap(map);
+ }
+ catch (Exception e) {
+ // An exception is expected.
+ }
+
+ assertTrue("The ServiceDescriptions should not have been built.", sdList == null);
+ }
+
+ public void testRespectBindingDisabled() throws Exception {
+ JavaClassToDBCConverter converter = new JavaClassToDBCConverter(DisabledService.class);
+ HashMap<String, DescriptionBuilderComposite> map = converter.produceDBC();
+
+ DescriptionBuilderComposite composite = map.get(DisabledService.class.getName());
+
+ URL wsdlUrl = new URL("file:./" + wsdlLocation);
+ WSDL4JWrapper wrapper = new WSDL4JWrapper(wsdlUrl, false, 0);
+
+ composite.setwsdlURL(wsdlUrl);
+ composite.setWsdlDefinition(wrapper.getDefinition());
- EndpointDescription ed = sd.getEndpointDescription(new QName(ns, plainServicePortName));
+ List<ServiceDescription> sdList = DescriptionFactory.createServiceDescriptionFromDBCMap(map);
+ ServiceDescription sd = sdList.get(0);
+
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns, disabledServicePortName));
assertTrue("The EndpointDescription should not be null.", ed != null);
boolean respect = ed.respectBinding();
- assertTrue("Strict binding support should be ENABLED.", respect);
+ assertFalse("Strict binding support should be DISABLED.", respect);
}
- public void testRespectBindingDisabled() {
- ServiceDescription sd = DescriptionFactory.createServiceDescription(DisabledService.class);
+ public void testRespectBindingDefault() throws Exception {
+ JavaClassToDBCConverter converter = new JavaClassToDBCConverter(DefaultService.class);
+ HashMap<String, DescriptionBuilderComposite> map = converter.produceDBC();
- EndpointDescription ed = sd.getEndpointDescription(new QName(ns, disabledServicePortName));
+ DescriptionBuilderComposite composite = map.get(DefaultService.class.getName());
+
+ URL wsdlUrl = new URL("file:./" + wsdlLocation);
+ WSDL4JWrapper wrapper = new WSDL4JWrapper(wsdlUrl, false, 0);
+
+ composite.setwsdlURL(wsdlUrl);
+ composite.setWsdlDefinition(wrapper.getDefinition());
+
+ List<ServiceDescription> sdList = DescriptionFactory.createServiceDescriptionFromDBCMap(map);
+ ServiceDescription sd = sdList.get(0);
+
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns, defaultServicePortName));
assertTrue("The EndpointDescription should not be null.", ed != null);
boolean respect = ed.respectBinding();
- assertFalse("Strict binding support should be DISABLED.", respect);
+ assertTrue("Strict binding support should be ENABLED.", respect);
}
@WebService(targetNamespace=ns, portName=plainServicePortName)
@RespectBinding
class PlainService {
- public double getQuote(String symbol) {
- return 101.01;
+ public String echo(String input) {
+ return "";
+ }
+ }
+
+ @WebService(targetNamespace=ns,
+ serviceName=serviceName,
+ portName=defaultServicePortName,
+ name=portTypeName,
+ wsdlLocation=wsdlLocation)
+ @RespectBinding
+ class DefaultService {
+ public String echo(String input) {
+ return "";
}
}
- @WebService(targetNamespace=ns, portName=disabledServicePortName)
+ @WebService(targetNamespace=ns,
+ serviceName=serviceName,
+ portName=disabledServicePortName,
+ name=portTypeName,
+ wsdlLocation=wsdlLocation)
@RespectBinding(enabled=false)
class DisabledService {
- public double getQuote(String symbol) {
- return 101.01;
+ public String echo(String input) {
+ return "";
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org