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/04/11 22:35:08 UTC
svn commit: r527652 - in
/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description:
./ impl/ validator/
Author: barrettj
Date: Wed Apr 11 13:35:06 2007
New Revision: 527652
URL: http://svn.apache.org/viewvc?view=rev&rev=527652
Log:
AXIS2-2308
Contributed by Roy Wood Jr. Client validation, disallow SOAP12 WSDL generation, check SEI vs Implementation
Modified:
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.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/EndpointInterfaceDescriptionImpl.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/EndpointInterfaceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java?view=diff&rev=527652&r1=527651&r2=527652
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointInterfaceDescription.java Wed Apr 11 13:35:06 2007
@@ -85,7 +85,7 @@
* @see #getOperation(QName operationQName)
*/
public abstract OperationDescription[] getDispatchableOperation(QName operationQName);
-
+ public abstract OperationDescription[] getDispatchableOperations();
public abstract OperationDescription getOperation(String operationName);
public abstract OperationDescription[] getOperations();
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?view=diff&rev=527652&r1=527651&r2=527652
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java Wed Apr 11 13:35:06 2007
@@ -78,5 +78,7 @@
public ServiceRuntimeDescription getServiceRuntimeDesc(String name);
public void setServiceRuntimeDesc(ServiceRuntimeDescription ord);
+
+ public boolean isServerSide();
}
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=527652&r1=527651&r2=527652
==============================================================================
--- 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 Wed Apr 11 13:35:06 2007
@@ -33,6 +33,7 @@
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter;
import org.apache.axis2.jaxws.description.validator.ServiceDescriptionValidator;
+import org.apache.axis2.jaxws.description.validator.EndpointDescriptionValidator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -216,6 +217,16 @@
EndpointDescription endpointDesc =
((ServiceDescriptionImpl)serviceDescription)
.updateEndpointDescription(sei, portQName, updateType);
+ EndpointDescriptionValidator endpointValidator = new EndpointDescriptionValidator(endpointDesc);
+
+ boolean isEndpointValid = endpointValidator.validate();
+
+ if (!isEndpointValid) {
+ String msg = "The Endpoint description validation failed to validate due to the following errors: \n" +
+ endpointValidator.toString();
+
+ throw ExceptionFactory.makeWebServiceException(msg);
+ }
if (log.isDebugEnabled()) {
log.debug("EndpointDescription updated: " + endpointDesc);
}
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=527652&r1=527651&r2=527652
==============================================================================
--- 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 Wed Apr 11 13:35:06 2007
@@ -296,78 +296,93 @@
buildDescriptionHierachy();
WsdlComposite wsdlComposite = null;
+
+ String bindingType = getBindingType();
+ boolean isSOAP12 = (bindingType.equals( javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
+ || bindingType.equals(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING))
+ ? true : false;
//Determine if we need to generate WSDL
- //Assumption is that WSDL will be generated only when the composite does not contain a
- //Wsdl Definition
- if (
- (isEndpointBased() &&
- DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface()))
- ||
- (!isEndpointBased())
- ) {
- //This is either an implicit SEI, or a WebService Provider
-
- wsdlComposite = generateWSDL(composite);
-
- } else if (isEndpointBased()) {
- //This impl class specifies an SEI...this is a special case. There is a bug
- //in the tooling that allows for the wsdllocation to be specifed on either the
- //impl. class, or the SEI, or both. So, we need to look for the wsdl as follows:
- // 1. If the Wsdl exists on the SEI, then check for it on the impl.
- // 2. If it is not found in either location, in that order, then generate
-
- DescriptionBuilderComposite seic =
- getServiceDescriptionImpl().getDBCMap()
- .get(composite.getWebServiceAnnot().endpointInterface());
-
- //Only generate WSDL if a definition doesn't already exist
- if (seic.getWsdlDefinition() == null)
+ //First, make sure that this is not a SOAP 1.2 based binding, per JAXWS spec. we cannot
+ //generate WSDL if the binding type is SOAP 1.2 based.
+ //Then, assuming the composite does not contain a
+ //Wsdl Definition, go ahead and generate it
+ // REVIEW: I think this should this be isSOAP11 so the generators are only called for
+ // SOAP11; i.e. NOT for SOAP12 or XML/HTTP bindings.
+ if (!isSOAP12) {
+ if (
+ (isEndpointBased() &&
+ DescriptionUtils.isEmpty(getAnnoWebServiceEndpointInterface()))
+ ||
+ (!isEndpointBased())
+ ) {
+ //This is either an implicit SEI, or a WebService Provider
+
wsdlComposite = generateWSDL(composite);
+
+ } else if (isEndpointBased()) {
+ //This impl class specifies an SEI...this is a special case. There is a bug
+ //in the tooling that allows for the wsdllocation to be specifed on either the
+ //impl. class, or the SEI, or both. So, we need to look for the wsdl as follows:
+ // 1. If the Wsdl exists on the SEI, then check for it on the impl.
+ // 2. If it is not found in either location, in that order, then generate
+
+ DescriptionBuilderComposite seic =
+ getServiceDescriptionImpl().getDBCMap()
+ .get(composite.getWebServiceAnnot().endpointInterface());
+
+ //Only generate WSDL if a definition doesn't already exist
+ if (seic.getWsdlDefinition() == null)
+ wsdlComposite = generateWSDL(composite);
+ }
+
+ } else if (composite.getWsdlDefinition() == null) {
+ //This is a SOAP12 binding that does not contain a WSDL definition, log a WARNING
+ log.warn("This implementation does not contain a WSDL definition and uses a SOAP 1.2 based binding. " +
+ "Per JAXWS spec. - a WSDL definition cannot be generated for this implementation. Name: "
+ + composite.getClassName());
}
- //Store the WsdlComposite only if it was created
- if (wsdlComposite != null) {
+ if (!isSOAP12) {
+
+ //Save the WSDL Location and the WsdlDefinition, value depends on whether wsdl was generated
+ Parameter wsdlLocationParameter = new Parameter();
+ wsdlLocationParameter.setName(MDQConstants.WSDL_LOCATION);
+
+ Parameter wsdlDefParameter = new Parameter();
+ wsdlDefParameter.setName(MDQConstants.WSDL_DEFINITION);
+
Parameter wsdlCompositeParameter = new Parameter();
wsdlCompositeParameter.setName(MDQConstants.WSDL_COMPOSITE);
- wsdlCompositeParameter.setValue(wsdlComposite);
-
+
+ if (wsdlComposite != null) {
+
+ //We have a wsdl composite, so set these values for the generated wsdl
+ wsdlCompositeParameter.setValue(wsdlComposite);
+ wsdlLocationParameter.setValue(wsdlComposite.getWsdlFileName());
+ wsdlDefParameter.setValue(
+ getServiceDescriptionImpl().getGeneratedWsdlWrapper().getDefinition());
+ } else if (getServiceDescriptionImpl().getWSDLWrapper() != null) {
+ //No wsdl composite because wsdl already exists
+ wsdlLocationParameter.setValue(getAnnoWebServiceWSDLLocation());
+ wsdlDefParameter.setValue(getServiceDescriptionImpl().getWSDLWrapper().getDefinition());
+ } else {
+ //There is no wsdl composite and there is NOT a wsdl definition
+ wsdlLocationParameter.setValue(null);
+ wsdlDefParameter.setValue(null);
+
+ }
+
try {
- axisService.addParameter(wsdlCompositeParameter);
+ if (wsdlComposite != null) {
+ axisService.addParameter(wsdlCompositeParameter);
+ }
+ axisService.addParameter(wsdlDefParameter);
+ axisService.addParameter(wsdlLocationParameter);
} catch (Exception e) {
throw ExceptionFactory.makeWebServiceException(
- "EndpointDescription: Unable to add wsdlComposite parm. to AxisService");
+ "EndpointDescription: Unable to add parameters to AxisService");
}
- }
-
- //Save the WSDL Location and the WsdlDefinition, value depends on whether wsdl was generated
- Parameter wsdlLocationParameter = new Parameter();
- wsdlLocationParameter.setName(MDQConstants.WSDL_LOCATION);
-
- Parameter wsdlDefParameter = new Parameter();
- wsdlDefParameter.setName(MDQConstants.WSDL_DEFINITION);
-
- if (wsdlComposite != null) {
-
- wsdlLocationParameter.setValue(wsdlComposite.getWsdlFileName());
- wsdlDefParameter.setValue(
- getServiceDescriptionImpl().getGeneratedWsdlWrapper().getDefinition());
- } else if (getServiceDescriptionImpl().getWSDLWrapper() != null) {
-
- wsdlLocationParameter.setValue(getAnnoWebServiceWSDLLocation());
- wsdlDefParameter.setValue(getServiceDescriptionImpl().getWSDLWrapper().getDefinition());
- } else {
- wsdlLocationParameter.setValue(null);
- wsdlDefParameter.setValue(null);
-
- }
-
- try {
- axisService.addParameter(wsdlDefParameter);
- axisService.addParameter(wsdlLocationParameter);
- } catch (Exception e) {
- throw ExceptionFactory.makeWebServiceException(
- "EndpointDescription: Unable to add parms. to AxisService");
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java?view=diff&rev=527652&r1=527651&r2=527652
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.java Wed Apr 11 13:35:06 2007
@@ -440,6 +440,26 @@
}
return returnOperations;
}
+ /* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.EndpointInterfaceDescription#getDispatchableOperations()
+ */
+ public OperationDescription[] getDispatchableOperations() {
+ OperationDescription[] returnOperations = null;
+ OperationDescription[] allMatchingOperations = getOperations();
+ if (allMatchingOperations != null && allMatchingOperations.length > 0) {
+ ArrayList<OperationDescription> dispatchableOperations = new ArrayList<OperationDescription>();
+ for (OperationDescription operation : allMatchingOperations) {
+ if (!operation.isJAXWSAsyncClientMethod()) {
+ dispatchableOperations.add(operation);
+ }
+ }
+
+ if (dispatchableOperations.size() > 0) {
+ returnOperations = dispatchableOperations.toArray(new OperationDescription[0]);
+ }
+ }
+ return returnOperations;
+ }
/**
* Return an OperationDescription for the corresponding SEI method. Note that this ONLY works
@@ -844,7 +864,9 @@
if (wsdlDefn != null) {
String tns = getEndpointDescription().getTargetNamespace();
String localPart = getEndpointDescription().getName();
- portType = wsdlDefn.getPortType(new QName(tns, localPart));
+ if (localPart != null) {
+ portType = wsdlDefn.getPortType(new QName(tns, localPart));
+ }
}
return portType;
}
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=527652&r1=527651&r2=527652
==============================================================================
--- 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 Wed Apr 11 13:35:06 2007
@@ -156,7 +156,12 @@
String serviceImplName = this.composite.getClassName();
this.dbcMap = dbcMap;
-//TODO: How to we get this when called from server side, create here for now
+ //TODO: How to we get this when called from server side, create here for now
+ //REVIEW: The value being set here is used later in validation checking to
+ // validation that should occur separately on server and client. If
+ // at some point this constructor is ever called by the client side,
+ // then we'll have to get smarter about how we determine server/client
+ // validation
this.isServerSide = true;
//capture the WSDL, if there is any...to be used for later processing
@@ -587,7 +592,7 @@
}
- boolean isServerSide() {
+ public boolean isServerSide() {
return isServerSide;
}
@@ -931,7 +936,8 @@
* compiler will take care of everything else.
*/
- HashMap compositeHashMap = new HashMap();
+ HashMap<String, MethodDescriptionComposite> compositeHashMap =
+ new HashMap<String, MethodDescriptionComposite>();
Iterator<MethodDescriptionComposite> compIterator =
composite.getMethodDescriptionsList().iterator();
while (compIterator.hasNext()) {
@@ -941,7 +947,8 @@
// Add methods declared in the implementation's superclass
addSuperClassMethods(compositeHashMap, composite);
- HashMap seiMethodHashMap = new HashMap();
+ HashMap<String, MethodDescriptionComposite> seiMethodHashMap =
+ new HashMap<String, MethodDescriptionComposite>();
Iterator<MethodDescriptionComposite> seiMethodIterator =
seic.getMethodDescriptionsList().iterator();
while (seiMethodIterator.hasNext()) {
@@ -957,16 +964,84 @@
seiMethodHashMap.values().iterator();
while (verifySEIIterator.hasNext()) {
MethodDescriptionComposite mdc = verifySEIIterator.next();
- // REVIEW: Only the names are checked; this isn't checking signatures
- if (compositeHashMap.get(mdc.getMethodName()) == null) {
+ MethodDescriptionComposite implMDC = compositeHashMap.get(mdc.getMethodName());
+
+ if (implMDC == null) {
// 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());
+ } else {
+ //At least we found it, now make sure that signatures match up
+
+ //Check for exceptions matching
+ validateMethodExceptions(mdc, implMDC, seic.getClassName());
+
+ // REVIEW: Probably should do other signature comparisons
+ }
+ }
+ }
+
+ private void validateMethodExceptions ( MethodDescriptionComposite seiMDC,
+ MethodDescriptionComposite implMDC,
+ String className) {
+
+ String[] seiExceptions = seiMDC.getExceptions();
+ String[] implExceptions = implMDC.getExceptions();
+
+ if (seiExceptions == null) {
+ if (implExceptions == null) {
+ return;
+ } else {
+ //Exception: sei list is null, but impl list is not null
+ throw ExceptionFactory.makeWebServiceException("Validation error: Implementation method signature does not match SEI method signature - mismatched exceptions list: Implementation class: "
+ + composite.getClassName()
+ + "; method name: " + seiMDC.getMethodName()
+ + "; endpointInterface: " + className);
+
}
+ } else if (implExceptions == null) {
+ //Exception: sei list is not null, but impl list is null
+ throw ExceptionFactory.makeWebServiceException("Validation error: Implementation method signature does not match SEI method signature - mismatched exceptions list: Implementation class: "
+ + composite.getClassName()
+ + "; method name: " + seiMDC.getMethodName()
+ + "; endpointInterface: " + className);
+
}
+
+ //check the list length
+ if (seiExceptions.length != implExceptions.length) {
+ throw ExceptionFactory.makeWebServiceException("Validation error: Implementation method signature does not match SEI method signature - mismatched exceptions list: Implementation class: "
+ + composite.getClassName()
+ + "; method name: " + seiMDC.getMethodName()
+ + "; endpointInterface: " + className);
+ }
+
+ if (seiExceptions.length > 0) {
+
+ for (String seiException : seiExceptions) {
+ boolean foundIt = false;
+ if (implExceptions.length > 0) {
+ for (String implException : implExceptions) {
+ if (seiException.equals(implException)) {
+ foundIt = true;
+ break;
+ }
+ }
+ }
+
+ if (!foundIt) {
+ throw ExceptionFactory.makeWebServiceException("Validation error: Implementation method signature does not match SEI method signature - mismatched exceptions list: Implementation class: "
+ + composite.getClassName()
+ + "; method name: " + seiMDC.getMethodName()
+ + "; endpointInterface: " + className);
+
+ }
+ }
+ }
+
}
/**
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=527652&r1=527651&r2=527652
==============================================================================
--- 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 Wed Apr 11 13:35:06 2007
@@ -48,12 +48,15 @@
return VALID;
}
- if (!validateWSDLPort()) {
- return INVALID;
- }
-
- if (!validateWSDLBindingType()) {
- return INVALID;
+ //The following phase II validation can only happen on the server side
+ if (endpointDesc.getServiceDescription().isServerSide()) {
+ if (!validateWSDLPort()) {
+ return INVALID;
+ }
+
+ if (!validateWSDLBindingType()) {
+ return INVALID;
+ }
}
if (!validateEndpointInterface()) {
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=527652&r1=527651&r2=527652
==============================================================================
--- 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 Wed Apr 11 13:35:06 2007
@@ -66,9 +66,11 @@
if (portType != null) {
// TODO: Need more validation here, including: operation name, parameters, faults
List wsdlOperationList = portType.getOperations();
- OperationDescription[] opDescArray = epInterfaceDesc.getOperations();
- if (wsdlOperationList.size() != opDescArray.length) {
+ OperationDescription[] dispatchableOpDescArray =
+ epInterfaceDesc.getDispatchableOperations();
+
+ if (wsdlOperationList.size() != dispatchableOpDescArray.length) {
addValidationFailure(this, "The number of operations in the WSDL " +
"portType does not match the number of methods in the SEI or " +
"Web service implementation class.");
@@ -76,8 +78,7 @@
}
// If they are the same size, let's check to see if the operation names match
-
- if (!checkOperationsMatchMethods(wsdlOperationList, opDescArray)) {
+ if (!checkOperationsMatchMethods(wsdlOperationList, dispatchableOpDescArray)) {
addValidationFailure(this, "The operation names in the WSDL portType " +
"do not match the method names in the SEI or Web service i" +
"mplementation class.");
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org