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 ch...@apache.org on 2005/07/07 12:15:55 UTC

svn commit: r209579 - in /webservices/axis/trunk/java/modules/wsdl: src/org/apache/axis2/wsdl/codegen/ src/org/apache/axis2/wsdl/codegen/extension/ test/org/apache/wsdl/

Author: chathura
Date: Thu Jul  7 03:15:52 2005
New Revision: 209579

URL: http://svn.apache.org/viewcvs?rev=209579&view=rev
Log:
A vilidator added that will check for possible erronious conditions in the WSDL.

Added:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/CodeGenerationEngine.java Thu Jul  7 03:15:52 2005
@@ -23,9 +23,12 @@
 import org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder;
 import org.apache.axis2.wsdl.codegen.extension.CodeGenExtension;
 import org.apache.axis2.wsdl.codegen.extension.PackageFinder;
+import org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension;
 import org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension;
 import org.apache.axis2.wsdl.databinding.TypeMapper;
 import org.apache.wsdl.WSDLDescription;
+import org.apache.wsdl.extensions.Schema;
+import org.w3c.dom.NamedNodeMap;
 
 import javax.wsdl.WSDLException;
 import java.io.File;
@@ -49,7 +52,7 @@
     public CodeGenerationEngine(CommandLineOptionParser parser) throws CodeGenerationException{
         WSDLDescription wom ;
         try {
-            wom = this.getWOM(parser);
+            wom = this.getWOM(parser);            
         }
         catch (WSDLException e) {
             throw new CodeGenerationException("Error parsing WSDL", e);
@@ -63,9 +66,15 @@
         axisBindingBuilder.init(this.configuration);
         axisBindingBuilder.engage();
 
+        WSDLValidatorExtension validatorExtension = new WSDLValidatorExtension();
+        validatorExtension.init(this.configuration);
+        this.moduleEndpoints.add(validatorExtension);
+        
         PackageFinder packageFinder = new PackageFinder();
         packageFinder.init(this.configuration);
         this.moduleEndpoints.add(packageFinder);
+        
+        
 
         XMLBeansExtension xmlBeanExtension = new XMLBeansExtension();
         xmlBeanExtension.init(this.configuration);

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java Thu Jul  7 03:15:52 2005
@@ -22,7 +22,7 @@
  * @author chathura@opensource.lk
  *
  */
-public class AbstractCodeGenerationExtension {
+public abstract class AbstractCodeGenerationExtension implements CodeGenExtension{
 
 	protected CodeGenConfiguration configuration;
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java Thu Jul  7 03:15:52 2005
@@ -17,6 +17,7 @@
 package org.apache.axis2.wsdl.codegen.extension;
 
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
 
 
 /**
@@ -28,7 +29,7 @@
 	
 	public void init(CodeGenConfiguration configuration);
 	
-	public void engage();
+	public void engage() throws CodeGenerationException;
 	
 	
 

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java Thu Jul  7 03:15:52 2005
@@ -28,8 +28,7 @@
  * @author chathura@opensource.lk
  *  
  */
-public class PackageFinder extends AbstractCodeGenerationExtension implements
-		CodeGenExtension {
+public class PackageFinder extends AbstractCodeGenerationExtension {
 
 	public void init(CodeGenConfiguration configuration) {
 		this.configuration = configuration;

Added: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java?rev=209579&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java Thu Jul  7 03:15:52 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.wsdl.codegen.extension;
+
+import java.util.Iterator;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.wsdl.WSDLDescription;
+import org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.w3c.dom.NamedNodeMap;
+
+/**
+ * @author chathura@opensource.lk
+ *
+ */
+public class WSDLValidatorExtension extends AbstractCodeGenerationExtension {
+	private static String TARGETNAMESPACE_STRING = "targetNamespace";
+	public void init(CodeGenConfiguration configuration) {
+        this.configuration = configuration;
+    }
+	
+	public void engage() throws CodeGenerationException{
+		WSDLDescription wom = this.configuration.getWom();
+		Iterator iterator = wom.getTypes().getExtensibilityElements().iterator();
+		while(iterator.hasNext()){
+			WSDLExtensibilityElement element = (WSDLExtensibilityElement)iterator.next();
+			boolean targetnamespaceFound = false;
+			if(ExtensionConstants.SCHEMA.equals(element.getType())){
+				Schema schema = (Schema)element;
+				NamedNodeMap attributes = schema.getElelment().getAttributes();
+				for(int i=0; i< attributes.getLength(); i++){
+					if(TARGETNAMESPACE_STRING.equalsIgnoreCase(attributes.item(i).getLocalName()))
+						targetnamespaceFound = true;
+				}
+			}
+			if(!targetnamespaceFound)
+				throw new CodeGenerationException("Invalid WSDL: The WSDL Types Schema does not define a targetNamespace");
+		}
+	}
+}

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java Thu Jul  7 03:15:52 2005
@@ -29,7 +29,7 @@
 *
 *
 */
-public class XMLBeansExtension extends AbstractCodeGenerationExtension implements CodeGenExtension {
+public class XMLBeansExtension extends AbstractCodeGenerationExtension {
     private static final String DEFUALT_STS_NAME = "foo";
 
 
@@ -54,6 +54,7 @@
                     Element schemaElement = ((Schema)extensiblityElt).getElelment();
 //                    //add the namespaces
                     XmlOptions options = new XmlOptions();
+                    options.setCompileDownloadUrls();
                     options.setLoadAdditionalNamespaces(configuration.getWom().getNamespaces());
                     //options.
                     xmlObjects[i] = XmlObject.Factory.parse(schemaElement,options);
@@ -66,6 +67,7 @@
         final File outputFolder =  configuration.getOutputLocation();
 
         try {
+        	
             SchemaTypeSystem sts = XmlBeans.compileXmlBeans(DEFUALT_STS_NAME, null,
                     xmlObjects,
                     new BindingConfig(), XmlBeans.getContextTypeLoader(),

Modified: webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java?rev=209579&r1=209578&r2=209579&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/test/org/apache/wsdl/WOMBuilderTest.java Thu Jul  7 03:15:52 2005
@@ -23,6 +23,8 @@
 import javax.wsdl.Operation;
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
+
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.Iterator;
@@ -44,7 +46,7 @@
 
     	WSDLVersionWrapper wsdlVersionWrapper = null;
         if (null == this.womDescription) {
-            InputStream in = new FileInputStream(getTestResourceFile("InteropTest.wsdl"));
+            InputStream in = new FileInputStream(new File("E:/temp/service.wsdl"));
             wsdlVersionWrapper = WOMBuilderFactory.getBuilder(WOMBuilderFactory.WSDL11).build(in);
 			this.womDescription = wsdlVersionWrapper.getDescription();
         }