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 ba...@apache.org on 2007/01/25 22:02:28 UTC
svn commit: r499969 - in /webservices/axis2/trunk/java/modules/metadata:
src/org/apache/axis2/jaxws/description/
src/org/apache/axis2/jaxws/description/builder/
src/org/apache/axis2/jaxws/description/impl/
src/org/apache/axis2/jaxws/description/validat...
Author: barrettj
Date: Thu Jan 25 13:02:26 2007
New Revision: 499969
URL: http://svn.apache.org/viewvc?view=rev&rev=499969
Log:
Enable validation errors found in annotations and/or WSDL to be thrown; enable additional validation checks for annotations and WSDL
Added:
webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplValidationTests.java
Modified:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.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/impl/ServiceDescriptionImpl.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointDescriptionValidator.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointInterfaceDescriptionValidator.java
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescriptionWSDL.java Thu Jan 25 13:02:26 2007
@@ -29,6 +29,16 @@
*
*/
public interface EndpointDescriptionWSDL {
+ /**
+ * Strings representing the SOAP Binding. These correspond to the namespace of the binding extensibility element under
+ * the WSDL binding. This could be SOAP or HTTP
+ */
+ public static final String SOAP11_WSDL_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/";
+ public static final String SOAP12_WSDL_BINDING = "http://schemas.xmlsoap.org/wsdl/soap12/";
+ public static final String HTTP_WSDL_BINDING = "http://schemas.xmlsoap.org/wsdl/http/";
+ /**
+ * QNames for the SOAP address extensiblity element under the WSDL Port element
+ */
public static final QName SOAP_11_ADDRESS_ELEMENT = new QName(Constants.URI_WSDL_SOAP11, "address");
public static final QName SOAP_12_ADDRESS_ELEMENT = new QName(Constants.URI_WSDL_SOAP12, "address");
@@ -43,7 +53,7 @@
* Typically, this is the <soap:binding> element that defines either a SOAP 1.1
* or a SOAP 1.2 binding.
*
- * @return
+ * @return String constants defined in javax.xml.ws.soap.SOAPBinding
*/
public String getWSDLBindingType();
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java Thu Jan 25 13:02:26 2007
@@ -185,35 +185,44 @@
public URL getWsdlURL() {
return this.wsdlURL;
}
-
- /**
- * Returns the nth occurence of this MethodComposite. Since
- * method names are not unique, we have to account for multiple occurrences
- *
- * @return Returns the methodDescriptionComposite.
- */
- public MethodDescriptionComposite getMethodDescriptionComposite(
- String methodName,
- int occurence) {
+ /** Returns a collection of all MethodDescriptionComposites that match the
+ * specified name
+ */
+ public List<MethodDescriptionComposite> getMethodDescriptionComposite(String methodName) {
+ ArrayList<MethodDescriptionComposite> matchingMethods = new ArrayList<MethodDescriptionComposite>();
+ Iterator<MethodDescriptionComposite> iter = methodDescriptions.iterator();
+ while(iter.hasNext()) {
+ MethodDescriptionComposite composite = iter.next();
+
+ if (composite.getMethodName() != null) {
+ if (composite.getMethodName().equals(methodName)){
+ matchingMethods.add(composite);
+ }
+ }
+ }
+
+ return matchingMethods;
+ }
- MethodDescriptionComposite composite = null;
- Iterator<MethodDescriptionComposite> iter =
- methodDescriptions.iterator();
- int hits = 0;
- while(iter.hasNext()) {
- composite = iter.next();
-
- if (composite.getMethodName() != null) {
- if (composite.getMethodName().equals(methodName)){
- hits++;
- if (hits == occurence)
- return composite;
- }
- }
- }
-
- return composite;
- }
+ /**
+ * Returns the nth occurence of this MethodComposite. Since
+ * method names are not unique, we have to account for multiple occurrences
+ *
+ * @param methodName
+ * @param occurence The nth occurance to return; not this is NOT 0 based
+ * @return Returns the methodDescriptionComposite
+ */
+ public MethodDescriptionComposite getMethodDescriptionComposite(
+ String methodName,
+ int occurence) {
+ MethodDescriptionComposite returnMDC = null;
+ List<MethodDescriptionComposite> matchingMethods = getMethodDescriptionComposite(methodName);
+ if (matchingMethods != null && !matchingMethods.isEmpty() &&
+ occurence > 0 && occurence <= matchingMethods.size() ) {
+ returnMDC = matchingMethods.get(--occurence);
+ }
+ return returnMDC;
+ }
public List<MethodDescriptionComposite> getMethodDescriptionsList() {
return methodDescriptions;
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java Thu Jan 25 13:02:26 2007
@@ -30,9 +30,9 @@
public static final String OBJECT_CLASS_NAME = "java.lang.Object";
- public static final String PROVIDER_SOURCE = "Provider<Source>";
- public static final String PROVIDER_SOAP = "Provider<SOAPMessage>";
- public static final String PROVIDER_DATASOURCE = "Provider<javax.activation.DataSource>";
+ public static final String PROVIDER_SOURCE = "javax.xml.ws.Provider<javax.xml.transform.Source>";
+ public static final String PROVIDER_SOAP = "javax.xml.ws.Provider<javax.xml.soap.SOAPMessage>";
+ public static final String PROVIDER_DATASOURCE = "javax.xml.ws.Provider<javax.activation.DataSource>";
public static final String WSDL_FILE_NAME = "WSDL_FILE_NAME";
public static final String SCHEMA_DOCS = "SCHEMA_DOCS";
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java Thu Jan 25 13:02:26 2007
@@ -37,6 +37,8 @@
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.validator.ServiceDescriptionValidator;
import org.apache.axis2.jaxws.description.validator.ValidationFailures;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Creates the JAX-WS metadata descritpion hierachy from some combinations of
@@ -44,6 +46,8 @@
* descriptors.
*/
public class DescriptionFactoryImpl {
+ private static final Log log = LogFactory.getLog(DescriptionFactoryImpl.class);
+
/**
* A DescrptionFactory can not be instantiated; all methods are static.
*/
@@ -85,6 +89,12 @@
String msg = "The ServiceDescription failed to validate due to the following errors: \n" +
validator.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Validation Phase 2 failure: " + msg);
+ log.debug("Failing composite: " + serviceImplComposite.toString());
+
+ }
// TODO: Validate all service descriptions before failing
// TODO: Get more detailed failure information from the Validator
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?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- 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 Thu Jan 25 13:02:26 2007
@@ -30,6 +30,7 @@
import javax.wsdl.PortType;
import javax.wsdl.WSDLException;
import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.http.HTTPBinding;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.wsdl.extensions.soap12.SOAP12Binding;
@@ -448,9 +449,9 @@
try {
// TODO: Using Class.forName() is probably not the best long-term way to get the SEI class from the annotation
seiClass = Class.forName(seiClassName, false, Thread.currentThread().getContextClassLoader());
- //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
- //does not extend Exception, so lets catch everything that extends Throwable
- //rather than just Exception.
+ // Catch Throwable as ClassLoader can throw an NoClassDefFoundError that
+ // does not extend Exception, so lets catch everything that extends Throwable
+ // rather than just Exception.
} catch (Throwable e) {
// TODO: Throwing wrong exception
e.printStackTrace();
@@ -694,8 +695,20 @@
isBuiltFromWSDL = true;
} catch (AxisFault e) {
- // TODO We should not swallow a fault here.
- log.warn(Messages.getMessage("warnAxisFault", e.toString()));
+ // REVIEW: If we couldn't use the WSDL, should we fail instead of continuing to process using annotations?
+ // Note that if we choose to fail, we need to distinguish the partial WSDL case (which can not fail)
+ // TODO: RAS/NLS Need to update the message with the appropriate inserts
+// log.warn(Messages.getMessage("warnAxisFault", e.toString()), e);
+ String wsdlLocation = (getServiceDescriptionImpl().getWSDLLocation() != null) ? getServiceDescriptionImpl().getWSDLLocation().toString() : null;
+ String implClassName = null;
+ if (getServiceDescriptionImpl().isDBCMap()) {
+ implClassName = composite.getClassName();
+ }
+ else {
+ implClassName = (implOrSEIClass != null) ? implOrSEIClass.getName() : null;
+ }
+ log.warn("The WSDL file could not be used due to an exception. The WSDL will be ignored and annotations will be used. Implementaiton class: "
+ + implClassName + "; WSDL Location: " + wsdlLocation +"; Exception: " + e.toString(), e);
isBuiltFromWSDL = false;
return isBuiltFromWSDL;
}
@@ -1171,7 +1184,7 @@
if (wsdlBinding != null) {
// If a WSDL binding was found, we need to find the proper extensibility
// element and return the namespace. The namespace will be different
- // for SOAP 1.1 vs. SOAP 1.2 bindings.
+ // for SOAP 1.1 vs. SOAP 1.2 bindings and HTTP.
// TODO: What do we do if no extensibility element exists?
List<ExtensibilityElement> elements = wsdlBinding.getExtensibilityElements();
Iterator<ExtensibilityElement> itr = elements.iterator();
@@ -1180,12 +1193,17 @@
if (javax.wsdl.extensions.soap.SOAPBinding.class.isAssignableFrom(e.getClass())) {
javax.wsdl.extensions.soap.SOAPBinding soapBnd = (javax.wsdl.extensions.soap.SOAPBinding) e;
wsdlBindingType = soapBnd.getElementType().getNamespaceURI();
- return wsdlBindingType;
+ break;
}
else if (SOAP12Binding.class.isAssignableFrom(e.getClass())) {
SOAP12Binding soapBnd = (SOAP12Binding) e;
wsdlBindingType = soapBnd.getElementType().getNamespaceURI();
- return wsdlBindingType;
+ break;
+ }
+ else if (HTTPBinding.class.isAssignableFrom(e.getClass())) {
+ HTTPBinding httpBnd = (HTTPBinding) e;
+ wsdlBindingType = httpBnd.getElementType().getNamespaceURI();
+ break;
}
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Thu Jan 25 13:02:26 2007
@@ -47,6 +47,7 @@
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.MDQConstants;
import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.util.WSDL4JWrapper;
import org.apache.axis2.jaxws.util.WSDLWrapper;
@@ -541,7 +542,7 @@
this.wsdlWrapper = wrapper;
}
- private void validateDBCLIntegrity(){
+ private void validateDBCLIntegrity() {
//First, check the integrity of this input composite
//and retrieve
@@ -558,9 +559,11 @@
validateIntegrity();
}
catch (Exception ex) {
- // TODO: This exception needs to be rethrown!
- //com.ibm.ws.ffdc.FFDCFilter.processException(ex, "org.apache.axis2.jaxws.description.ServiceDescription", "329", this);
- //Tr.error(_tc, msg, inserts);
+ if (log.isDebugEnabled()) {
+ log.debug("Validation phase 1 failure: " + ex.toString(), ex);
+ log.debug("Failing composite: " + composite.toString());
+ }
+ throw ExceptionFactory.makeWebServiceException("Validation Exception " + ex, ex);
}
}
@@ -584,18 +587,26 @@
Iterator<String> iter =
composite.getInterfacesList().iterator();
+ // Remember if we've validated the Provider interface. Later we'll make sure that if we have an
+ // WebServiceProvider annotation, we found a valid interface here.
+ boolean providerInterfaceValid = false;
while (iter.hasNext()) {
String interfaceString = iter.next();
- // REVIEW: These string compares may not be sufficient; they assume, for example Provider<SOAPMessage>. What about endpoint impls that:
- // (1) ... implement Provider<javax.xml.soap.SOAPMessage>
- // (2) import wrong.package.SOAPMessage;
- // ... implement Provider<SOAPMessage>;
if (interfaceString.equals(MDQConstants.PROVIDER_SOURCE)
|| interfaceString.equals(MDQConstants.PROVIDER_SOAP)
|| interfaceString.equals(MDQConstants.PROVIDER_DATASOURCE)) {
- //This is a provider based SEI, make sure the annotation exists
+ providerInterfaceValid = true;
+ //This is a provider based endpoint, make sure the annotation exists
if (composite.getWebServiceProviderAnnot() == null) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: This is a Provider based SEI that does not contain a WebServiceProvider annotation");
+ // TODO: (VALIDATION) Don't throw this yet because a LOT of provider tests fail validation with it!
+ if (true) {
+ log.error("FIXME: Validation error that is currently allowed: This is a Provider based endpoint that does not contain a WebServiceProvider annotation. Provider class: " + composite.getClassName());
+ log.debug("Failing composite: " + composite.toString());
+ }
+ else {
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: This is a Provider based endpoint that does not contain a WebServiceProvider annotation. Provider class: " + composite.getClassName());
+ }
}
}
}
@@ -605,17 +616,30 @@
//Verify that WebService and WebServiceProvider are not both specified
//per JAXWS - Sec. 7.7
if (composite.getWebServiceAnnot() != null && composite.getWebServiceProviderAnnot() != null) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: WebService annotation and WebServiceProvider annotation cannot coexist");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: WebService annotation and WebServiceProvider annotation cannot coexist. Implementation class: " + composite.getClassName());
}
-// Make sure that we're only validating against WSDL, if there is WSDL...duh
if (composite.getWebServiceProviderAnnot() != null ) {
- // TODO: Verify that this Provider based WebService has a method named invoke
-
+ if (!providerInterfaceValid) {
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: This is a Provider that does not specify a valid Provider interface. Implementation class: " + composite.getClassName());
+ }
+ // There must be a public default constructor per JAXWS - Sec 5.1
+ if (!validateDefaultConstructor()) {
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: Provider must have a public default constructor. Implementation class: " + composite.getClassName());
+ }
+ // There must be an invoke method per JAXWS - Sec 5.1.1
+ if (!validateInvokeMethod()) {
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: Provider must have a public invoke method. Implementation class: " + composite.getClassName());
+ }
} else if (composite.getWebServiceAnnot() != null) {
if ( composite.getServiceModeAnnot() != null) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: ServiceMode annotation can only be specified for WebServiceProvider");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: ServiceMode annotation can only be specified for WebServiceProvider. Implementation class: " + composite.getClassName());
}
//TODO: hmmm, will we ever actually validate an interface directly...don't think so
@@ -626,7 +650,9 @@
// TODO: Validate on the class that a finalize() method does not exist
if (!DescriptionUtils.isEmpty(composite.getWebServiceAnnot().wsdlLocation())) {
if (composite.getWsdlDefinition() == null && composite.getWsdlURL() == null) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: cannot find WSDL Definition pertaining to this WebService annotation");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: cannot find WSDL Definition specified by this WebService annotation. Implementation class: "
+ + composite.getClassName() + "; WSDL location: " + composite.getWebServiceAnnot().wsdlLocation());
}
}
@@ -638,7 +664,9 @@
//Verify that we can find the SEI in the composite list
if (seic == null){
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: cannot find SEI composite specified by the endpoint interface");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: cannot find SEI specified by the WebService.endpointInterface. Implementaiton class: "
+ + composite.getClassName() + "; EndpointInterface: " + composite.getWebServiceAnnot().endpointInterface());
}
// Verify that the only class annotations are WebService and HandlerChain
@@ -650,28 +678,38 @@
|| composite.getWebServiceContextAnnot()!= null
|| !composite.getAllWebServiceRefAnnots().isEmpty()
) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: invalid annotations specified when WebService annotation specifies an endpoint interface: "
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: invalid annotations specified when WebService annotation specifies an endpoint interface. Implemntation class: "
+ composite.getClassName());
}
//Verify that WebService annotation does not contain a name attribute
//(per JSR181 Sec. 3.1)
if (composite.getWebServiceAnnot().name() != null) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: invalid annotations specified when WebService annotation specifies an endpoint interface: " +
- composite.getClassName());
+ // TODO: (VALIDATION) Don't throw this yet because a LOT of provider tests fail validation with it!
+ if (true) {
+ log.error("FIXME: Validation error currently allowed: WebService.name must not be specified when the bean specifies an endpoint interface. Implentation class: "
+ + composite.getClassName() + "; WebService.name: " + composite.getWebServiceAnnot().name());
+ log.debug("Failing composite: " + composite.toString());
+ }
+ else {
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: WebService.name must not be specified when the bean specifies an endpoint interface. Implentation class: "
+ + composite.getClassName() + "; WebService.name: " + composite.getWebServiceAnnot().name());
+ }
}
+ validateSEI(seic);
//Verify that that this implementation class implements all methods in the interface
validateImplementation(seic);
//Verify that this impl. class does not contain any @WebMethod annotations
if (webMethodAnnotationsExist()) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: WebMethod annotations cannot exist on class when WebService.endpointInterface is set");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: WebMethod annotations cannot exist on implentation when WebService.endpointInterface is set. Implementation class: " +
+ composite.getClassName());
}
- //TODO: validateSEI() ...this should really be done here. No sense in validating
- // an interface just because its in the list
- validateSEI(seic);
} else { //this is an implicit SEI (i.e. impl w/out endpointInterface
@@ -681,7 +719,9 @@
//
}
} else { //this is an interface...we should not be processing interfaces here
- throw ExceptionFactory.makeWebServiceException("ValidateIntegrity: Improper usage: cannot invoke this method with an interface");
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: Improper usage: cannot invoke this method with an interface. Implementation class: "
+ + composite.getClassName());
}
//TODO: don't think this is necessary
@@ -689,7 +729,41 @@
}
}
- private void validateImplementation(DescriptionBuilderComposite seic) {
+ /**
+ * Validate there is an invoke method on the composite.
+ * @return
+ */
+ private boolean validateInvokeMethod() {
+ boolean validInvokeMethod = false;
+ List<MethodDescriptionComposite> invokeMethodList = composite.getMethodDescriptionComposite("invoke");
+ if (invokeMethodList != null && !invokeMethodList.isEmpty()) {
+ validInvokeMethod = true;
+ }
+ return validInvokeMethod;
+ }
+
+ /**
+ * Validate there is a default no-argument constructor on the composite.
+ * @return
+ */
+ private boolean validateDefaultConstructor() {
+ boolean validDefaultCtor = false;
+ List<MethodDescriptionComposite> constructorList = composite.getMethodDescriptionComposite("<init>");
+ if (constructorList != null && !constructorList.isEmpty()) {
+ // There are public constructors; make sure there is one that takes no arguments.
+ for (MethodDescriptionComposite checkCtor : constructorList) {
+ List<ParameterDescriptionComposite> paramList = checkCtor.getParameterDescriptionCompositeList();
+ if (paramList == null || paramList.isEmpty()) {
+ validDefaultCtor = true;
+ break;
+ }
+ }
+ }
+
+ return validDefaultCtor;
+ }
+
+ private void validateImplementation(DescriptionBuilderComposite seic) {
/*
* Verify that an impl class implements all the methods of the SEI. We
* have to verify this because an impl class is not required to actually use
@@ -724,12 +798,11 @@
MethodDescriptionComposite mdc = verifySEIIterator.next();
// REVIEW: Only the names are checked; this isn't checking signatures
if (compositeHashMap.get(mdc.getMethodName()) == null) {
- throw ExceptionFactory.makeWebServiceException("ServiceDescription: subclass does not implement method on specified interface: " +
- "method name: " + mdc.getMethodName() + " endpointInterface: " + seic.getClassName() +
- " implementation class: " + composite.getClassName());
+ // TODO: RAS/NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: Implementation subclass does not implement method on specified interface. Implementation class: "
+ + composite.getClassName() + "; missing method name: " + mdc.getMethodName() + "; endpointInterface: " + seic.getClassName());
}
}
-
}
/**
* Adds any methods declared in superclasses to the HashMap. The hierachy starting with the DBC will be walked
@@ -801,9 +874,16 @@
//TODO: Validate SEI superclasses -- hmmm, may be doing this below
//
-
+ if (seic.getWebServiceAnnot() == null) {
+ // TODO: RAS & NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: SEI does not contain a WebService annotation. Implementation class: "
+ + composite.getClassName() + "; SEI: " + seic.getClassName());
+ }
if (!seic.getWebServiceAnnot().endpointInterface().equals("")) {
- throw ExceptionFactory.makeWebServiceException("DescriptionBuilderComposite: WebService annotation contains a non-empty field for the SEI");
+ // TODO: RAS & NLS
+ throw ExceptionFactory.makeWebServiceException("Validation error: SEI must not set a value for @WebService.endpointInterface. Implementation class: "
+ + composite.getClassName() + "; SEI: " + seic.getClassName()
+ + "; Invalid endpointInterface value: " + seic.getWebServiceAnnot().endpointInterface());
}
checkSEIAgainstWSDL();
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?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- 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 Thu Jan 25 13:02:26 2007
@@ -20,6 +20,8 @@
import javax.wsdl.Port;
import javax.wsdl.Service;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.soap.SOAPBinding;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
@@ -63,14 +65,60 @@
private boolean validateWSDLBindingType() {
// TODO: The getWSDLBindingType is not getting the correct value; it needs to return the
// <soap:binding transport> value
- if (true) return VALID;
+ boolean isBindingValid = false;
String bindingType = endpointDesc.getBindingType();
String wsdlBindingType = endpointDescWSDL.getWSDLBindingType();
- if (wsdlBindingType != null && !wsdlBindingType.equals(bindingType)) {
- addValidationFailure(this, "Binding type is invald");
- return INVALID;
+ if (bindingType == null) {
+ // I don't think this can happen; the Description layer should provide a default
+ addValidationFailure(this, "Annotation binding type is null and did not have a default");
+ isBindingValid = false;
}
- return VALID;
+ // Validate that the annotation value specified is valid.
+ else if (!SOAPBinding.SOAP11HTTP_BINDING.equals(bindingType) &&
+ !SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bindingType) &&
+ !SOAPBinding.SOAP12HTTP_BINDING.equals(bindingType) &&
+ !SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bindingType) &&
+ !HTTPBinding.HTTP_BINDING.equals(bindingType)) {
+ addValidationFailure(this, "Invalid annotation binding value specified: " + bindingType);
+ isBindingValid = false;
+ }
+ // If there's no WSDL, then there will be no WSDL Binding Type to validate against
+ else if (wsdlBindingType == null) {
+ isBindingValid = true;
+ }
+ // Validate that the WSDL value is valid
+ else if (!EndpointDescriptionWSDL.SOAP11_WSDL_BINDING.equals(wsdlBindingType) &&
+ !EndpointDescriptionWSDL.SOAP12_WSDL_BINDING.equals(wsdlBindingType) &&
+ !EndpointDescriptionWSDL.HTTP_WSDL_BINDING.equals(wsdlBindingType)) {
+ addValidationFailure(this, "Invalid wsdl binding value specified: " + wsdlBindingType);
+ isBindingValid = false;
+ }
+ // Validate that the WSDL and annotations values indicate the same type of binding
+ else if (wsdlBindingType.equals(EndpointDescriptionWSDL.SOAP11_WSDL_BINDING)
+ && (bindingType.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
+ bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING))) {
+ isBindingValid = true;
+ }
+ else if (wsdlBindingType.equals(EndpointDescriptionWSDL.SOAP12_WSDL_BINDING)
+ && (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) ||
+ bindingType.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
+ isBindingValid = true;
+ }
+ else if (wsdlBindingType.equals(EndpointDescriptionWSDL.HTTP_WSDL_BINDING) &&
+ bindingType.equals(HTTPBinding.HTTP_BINDING)) {
+ isBindingValid = true;
+ }
+ // The HTTP binding is not valid on a Java Bean SEI-based endpoint; only on a Provider based one.
+ else if (wsdlBindingType.equals(EndpointDescriptionWSDL.HTTP_WSDL_BINDING) &&
+ endpointDesc.isEndpointBased()) {
+ addValidationFailure(this, "The HTTPBinding can not be specified for SEI-based endpoints");
+ isBindingValid = false;
+ }
+ else {
+ addValidationFailure(this, "Invalid binding; wsdl = " + wsdlBindingType + ", annotation = " + bindingType);
+ isBindingValid = false;
+ }
+ return isBindingValid;
}
private boolean validateWSDLPort() {
@@ -81,7 +129,8 @@
if (wsdlService != null) {
Port wsdlPort = endpointDescWSDL.getWSDLPort();
if (wsdlPort == null) {
- addValidationFailure(this, "Serivce exists in WSDL, but Port does not. Not a valid Partial WSDL");
+ addValidationFailure(this, "Serivce exists in WSDL, but Port does not. Not a valid Partial WSDL. Service: "
+ + endpointDesc.getServiceQName() + "; Port: " + endpointDesc.getPortQName());
return INVALID;
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointInterfaceDescriptionValidator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointInterfaceDescriptionValidator.java?view=diff&rev=499969&r1=499968&r2=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointInterfaceDescriptionValidator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/validator/EndpointInterfaceDescriptionValidator.java Thu Jan 25 13:02:26 2007
@@ -81,8 +81,8 @@
addValidationFailure(this, "The operation names in the WSDL portType " +
"do not match the method names in the SEI or Web service i" +
"mplementation class.");
+ return INVALID;
}
-
}
return VALID;
}
Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplValidationTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplValidationTests.java?view=auto&rev=499969
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplValidationTests.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplValidationTests.java Thu Jan 25 13:02:26 2007
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.description.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.WebServiceAnnot;
+import org.apache.axis2.jaxws.description.builder.WebServiceProviderAnnot;
+import org.apache.axis2.jaxws.description.builder.WsdlComposite;
+import org.apache.axis2.jaxws.description.builder.WsdlGenerator;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class ServiceDescriptionImplValidationTests extends TestCase {
+
+ public void testValidateImplMethodsVsSEI() {
+
+ DescriptionBuilderComposite seiComposite = new DescriptionBuilderComposite();
+ seiComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySEI");
+ MethodDescriptionComposite seiMDC = new MethodDescriptionComposite();
+ seiMDC.setMethodName("seiMethod");
+ seiComposite.addMethodDescriptionComposite(seiMDC);
+
+ DescriptionBuilderComposite implComposite = new DescriptionBuilderComposite();
+ implComposite.setClassName("org.apache.axis2.jaxws.description.impl.MyImpl");
+ MethodDescriptionComposite implMDC = new MethodDescriptionComposite();
+ implMDC.setMethodName("notSeiMethod");
+ implComposite.addMethodDescriptionComposite(implMDC);
+ WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+ webServiceAnnot.setName(null);
+ webServiceAnnot.setEndpointInterface("org.apache.axis2.jaxws.description.impl.MySEI");
+ implComposite.setWebServiceAnnot(webServiceAnnot);
+ implComposite.setIsInterface(false);
+
+ HashMap<String, DescriptionBuilderComposite> dbcList = new HashMap<String, DescriptionBuilderComposite>();
+ dbcList.put(seiComposite.getClassName(), seiComposite);
+ dbcList.put(implComposite.getClassName(), implComposite);
+
+ try {
+ ServiceDescriptionImpl serviceDescImpl = new ServiceDescriptionImpl(dbcList, implComposite);
+ fail("Should have caught exception for validation errors");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Caught wrong type of exception " + ex.toString());
+ }
+
+
+ }
+ public void testValidateImplMethodsVsSEIInheritence() {
+
+ DescriptionBuilderComposite superSeiComposite = new DescriptionBuilderComposite();
+ superSeiComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySuperSEI");
+ MethodDescriptionComposite superSeiMDC = new MethodDescriptionComposite();
+ superSeiMDC.setMethodName("superSeiMethod");
+ superSeiComposite.addMethodDescriptionComposite(superSeiMDC);
+
+ DescriptionBuilderComposite seiComposite = new DescriptionBuilderComposite();
+ seiComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySEI");
+ MethodDescriptionComposite seiMDC = new MethodDescriptionComposite();
+ seiMDC.setMethodName("seiMethod");
+ seiComposite.addMethodDescriptionComposite(seiMDC);
+ seiComposite.setSuperClassName("org.apache.axis2.jaxws.description.impl.MySuperSEI");
+
+ DescriptionBuilderComposite implComposite = new DescriptionBuilderComposite();
+ implComposite.setClassName("org.apache.axis2.jaxws.description.impl.MyImpl");
+ MethodDescriptionComposite implMDC = new MethodDescriptionComposite();
+ implMDC.setMethodName("superSeiMethod");
+ implComposite.addMethodDescriptionComposite(implMDC);
+ WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+ webServiceAnnot.setName(null);
+ webServiceAnnot.setEndpointInterface("org.apache.axis2.jaxws.description.impl.MySEI");
+ implComposite.setWebServiceAnnot(webServiceAnnot);
+ implComposite.setIsInterface(false);
+
+ HashMap<String, DescriptionBuilderComposite> dbcList = new HashMap<String, DescriptionBuilderComposite>();
+ dbcList.put(seiComposite.getClassName(), seiComposite);
+ dbcList.put(superSeiComposite.getClassName(), superSeiComposite);
+ dbcList.put(implComposite.getClassName(), implComposite);
+
+ try {
+ ServiceDescriptionImpl serviceDescImpl = new ServiceDescriptionImpl(dbcList, implComposite);
+ fail("Should have caught validation failure exception");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Caught wrong exception " + ex.toString());
+ }
+ }
+
+ // The tests below progressively setup an identical DBC, gradually setting more values until
+ // the last one does not cause a validation error.
+
+ // FAILURE #1: No WebMethod annotation set on the SEI
+ public void testInvalidDBC1() {
+ DescriptionBuilderComposite seiComposite = new DescriptionBuilderComposite();
+ seiComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySEI");
+ MethodDescriptionComposite seiMDC = new MethodDescriptionComposite();
+ seiMDC.setMethodName("seiMethod");
+ seiComposite.addMethodDescriptionComposite(seiMDC);
+
+ DescriptionBuilderComposite superImplComposite = new DescriptionBuilderComposite();
+ superImplComposite.setClassName("org.apache.axis2.jaxws.description.impl.MySuperImpl");
+ MethodDescriptionComposite superImplMDC = new MethodDescriptionComposite();
+ superImplMDC.setMethodName("seiMethod");
+ superImplComposite.addMethodDescriptionComposite(superImplMDC);
+
+ DescriptionBuilderComposite implComposite = new DescriptionBuilderComposite();
+ implComposite.setClassName("org.apache.axis2.jaxws.description.impl.MyImpl");
+ MethodDescriptionComposite implMDC = new MethodDescriptionComposite();
+ implMDC.setMethodName("notSeiMethod");
+ implComposite.addMethodDescriptionComposite(implMDC);
+ WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+ webServiceAnnot.setName(null);
+ webServiceAnnot.setEndpointInterface("org.apache.axis2.jaxws.description.impl.MySEI");
+ implComposite.setWebServiceAnnot(webServiceAnnot);
+ implComposite.setIsInterface(false);
+ implComposite.setSuperClassName("org.apache.axis2.jaxws.description.impl.MySuperImpl");
+
+ HashMap<String, DescriptionBuilderComposite> dbcList = new HashMap<String, DescriptionBuilderComposite>();
+ dbcList.put(seiComposite.getClassName(), seiComposite);
+ dbcList.put(implComposite.getClassName(), implComposite);
+ dbcList.put(superImplComposite.getClassName(), superImplComposite);
+
+ try {
+ ServiceDescriptionImpl serviceDescImpl = new ServiceDescriptionImpl(dbcList, implComposite);
+ fail("Did not catch expected exception");
+ }
+ catch (WebServiceException ex) {
+ // Expected path
+ }
+ catch (Exception ex) {
+ fail("Unexpected exception received " + ex.toString());
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org