Author: ajith
Date: Thu Nov  3 04:30:28 2005
New Revision: 330532

URL: http://svn.apache.org/viewcvs?rev=330532&view=rev
Log:
1.Added a new ant build file generator/template to the codegen
  The config file/Emitter is also modified
2.Modified the WSDLPump.java to process imports
3.Added a newline that adds a feature to the WSDL reader in 
WSDL1ToWOMBuilder.java

Added:
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
Modified:
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
    
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
    
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java

Modified: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/schema/SchemaCompiler.java
 Thu Nov  3 04:30:28 2005
@@ -234,6 +234,8 @@
         if (isArray){

             //append the square braces that say this is an array

             //hope this works for all cases!!!!!!!

+            //todo this however is a thing that needs to be

+            //todo fixed to get complete language support

             className = className + "[]";

         }

         return className;


Modified: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
 Thu Nov  3 04:30:28 2005
@@ -40,6 +40,7 @@
         public static final int XML_BEANS = 1;
         public static final int JAXB = 2;
         public static final int ADB = 3;
+        public static final int USER = 4;
 
     }
 

Modified: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
 (original)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
 Thu Nov  3 04:30:28 2005
@@ -48,6 +48,7 @@
 
java.dbsupporter.adb.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/ADBSupporterTemplate.xsl

 ###########

 
java.dbsupporter.default.template=org.apache.axis2.wsdl.codegen.writer.DatabindingSupportClassWriter,/org/apache/axis2/wsdl/template/java/DefaultDataBindingSupporterTemplate.xsl

+java.antbuild.template=org.apache.axis2.wsdl.codegen.writer.AntBuildWriter,/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl

 # file extension for generated files from this language

 java.filename.extension=java

 #


Modified: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
 Thu Nov  3 04:30:28 2005
@@ -79,7 +79,7 @@
      */
     public void setMapper(TypeMapper mapper) {
         this.mapper = mapper;
-       
+
     }
 
     /**
@@ -266,6 +266,8 @@
                 //writeTestSkeletonImpl(axisBinding);
                 //write a testservice.xml that will load the dummy skeleton 
impl for testing
                 //writeTestServiceXML(axisBinding);
+                //write an ant build file
+                writeAntBuild(axisBinding.getBoundInterface(),axisBinding);
             }
         }
     }
@@ -405,9 +407,25 @@
 
     }
 
+    /**
+     * Writes the Ant build
+     *
+     * @param axisInterface
+     * @param axisBinding
+     * @throws Exception
+     */
+    protected void writeAntBuild(WSDLInterface axisInterface, WSDLBinding 
axisBinding) throws Exception {
+        //Write the service xml in a folder with the
+        Document skeletonModel = createDOMDocumentForInterface(
+                axisInterface, axisBinding);
+        ClassWriter antBuildWriter = new AntBuildWriter(
+                this.configuration.getOutputLocation(),
+                this.configuration.getOutputLanguage());
+        writeClass(skeletonModel, antBuildWriter);
+    }
 
     /**
-     * Writes the skeleton
+     * Writes the Service XML
      *
      * @param axisInterface
      * @param axisBinding
@@ -882,9 +900,12 @@
             if (null != binding) {
                 WSDLBindingOperation bindingOperation =
                         binding.getBindingOperation(operation.getName());
-                addSOAPAction(doc, methodElement, bindingOperation);
-                
addHeaderOperations(soapHeaderInputParameterList,bindingOperation,true);
-                
addHeaderOperations(soapHeaderOutputParameterList,bindingOperation,false);
+                // todo This can be a prob !!!!!
+                if (bindingOperation!=null){
+                    addSOAPAction(doc, methodElement, bindingOperation);
+                    
addHeaderOperations(soapHeaderInputParameterList,bindingOperation,true);
+                    
addHeaderOperations(soapHeaderOutputParameterList,bindingOperation,false);
+                }
             }
 
             methodElement.appendChild(getInputElement(doc, operation, 
soapHeaderInputParameterList));

Modified: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
 Thu Nov  3 04:30:28 2005
@@ -101,6 +101,9 @@
             }
 
             List typesArray = typesList.getExtensibilityElements();
+            //this a list that keeps the already processed schemas
+            List processedSchemas = new ArrayList();
+
             WSDLExtensibilityElement extensiblityElt;
             SchemaTypeSystem sts = null;
             Vector xmlObjectsVector = new Vector();
@@ -125,23 +128,28 @@
                     //compile these schemas
                     while (!importedSchemaStack.isEmpty()) {
                         Element element = (Element)importedSchemaStack.pop();
+                        String tagetNamespace = 
element.getAttribute("targetNamespace");
+                        if (!processedSchemas.contains(tagetNamespace)){
+
+                            // we are not using DOM toString method here, as 
it seems it depends on the
+                            // JDK version that is being used.
+                            String s = DOM2Writer.nodeToString(element);
+
+                            //write the schema to a file
+                            File tempFile = File.createTempFile("temp", 
".xsd", schemaFolder);
+                            FileWriter writer = new FileWriter(tempFile);
+                            writer.write(s);
+                            writer.flush();
+                            writer.close();
+
+
+                            xmlObjectsVector.add(
+                                    XmlObject.Factory.parse(
+                                            element
+                                            , options));
 
-                        // we are not using DOM toString method here, as it 
seems it depends on the
-                        // JDK version that is being used.
-                        String s = DOM2Writer.nodeToString(element);
-
-                        //write the schema to a file
-                        File tempFile = File.createTempFile("temp", ".xsd", 
schemaFolder);
-                        FileWriter writer = new FileWriter(tempFile);
-                        writer.write(s);
-                        writer.flush();
-                        writer.close();
-
-
-                        xmlObjectsVector.add(
-                                XmlObject.Factory.parse(
-                                        element
-                                        , options));
+                            processedSchemas.add(tagetNamespace);
+                        }
                     }
                 }
             }
@@ -268,9 +276,11 @@
             DocumentBuilder documentBuilder = 
getNamespaceAwareDocumentBuilder();
             for (int i = 0; i < schemaNames.length; i++) {
                 //the location for the third party schema;s is hardcoded
-                InputStream schemaStream = 
this.getClass().getResourceAsStream("/org/apache/axis2/wsdl/codegen/schema/" + 
schemaNames[i]);
-                Document doc = documentBuilder.parse(schemaStream);
-                additionalSchemaElements.add(doc.getDocumentElement());
+                if (!"".equals(schemaNames[i].trim())){
+                    InputStream schemaStream = 
this.getClass().getResourceAsStream("/org/apache/axis2/wsdl/codegen/schema/" + 
schemaNames[i]);
+                    Document doc = documentBuilder.parse(schemaStream);
+                    additionalSchemaElements.add(doc.getDocumentElement());
+                }
             }
 
             //Create the Schema element array
@@ -329,11 +339,7 @@
     }
 
     private XmlObject[] convertToXMLObjectArray(Vector vec) {
-        XmlObject[] xmlObjects = new XmlObject[vec.size()];
-        for (int i = 0; i < vec.size(); i++) {
-            xmlObjects[i] = (XmlObject) vec.get(i);
-        }
-        return xmlObjects;
+        return (XmlObject[])vec.toArray(new XmlObject[vec.size()]);
     }
 
     /**

Added: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java?rev=330532&view=auto
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java
 (added)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/AntBuildWriter.java
 Thu Nov  3 04:30:28 2005
@@ -0,0 +1,46 @@
+package org.apache.axis2.wsdl.codegen.writer;

+

+import org.apache.axis2.util.FileWriter;

+

+import java.io.File;

+import java.io.FileOutputStream;

+/*

+ * Copyright 2004,2005 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.

+ */

+

+public class AntBuildWriter extends ClassWriter{

+     public AntBuildWriter(String outputFileLocation) {

+        this.outputFileLocation = new File(outputFileLocation);

+    }

+

+    public AntBuildWriter(File outputFileLocation, String language) {

+        this.outputFileLocation = outputFileLocation;

+        this.language = language;

+    }

+

+

+

+    public void createOutFile(String packageName, String fileName) throws 
Exception {

+        File outputFile = FileWriter.createClassFile(outputFileLocation,

+                "",

+                packageName.replaceAll("\\.","_")+"build",

+                ".xml");

+        //set the existing flag

+        fileExists = outputFile.exists();

+        if (!fileExists){

+            this.stream = new FileOutputStream(outputFile);

+        }

+    }

+}


Added: 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl?rev=330532&view=auto
==============================================================================
--- 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
 (added)
+++ 
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/general/xmlbeansAntBuildTemplate.xsl
 Thu Nov  3 04:30:28 2005
@@ -0,0 +1,147 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

+    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

+    <xsl:template match="/interface">

+        <xsl:variable name="package"><xsl:value-of 
select="@package"/></xsl:variable>

+

+        <project basedir="." default="jar.xbeans"  >

+            <xsl:comment>Auto generated ant build file</xsl:comment>

+            <property name="src">

+                <xsl:attribute name="value">${basedir}\src</xsl:attribute>

+            </property>

+            <property name="classes">

+                <xsl:attribute name="value">${basedir}\classes</xsl:attribute>

+            </property>

+            <property name="bin">

+                <xsl:attribute name="value">${basedir}\bin</xsl:attribute>

+            </property>

+            <property name="other">

+                <xsl:attribute name="value">${basedir}\other</xsl:attribute>

+            </property>

+            <property name="temp">

+                <xsl:attribute name="value">${basedir}\temp</xsl:attribute>

+            </property>

+            <property name="xbeans.packaged.jar.name" 
value="XBeans-packaged.jar"></property>

+            <!--<property name="xbeans.jar.name" value="C:\Documents and 
Settings\Ajith\.maven\repository\xmlbeans\jars\xbean-2.0.0.jar"></property>-->

+            <property name="xbeans.available" value=""></property>

+            <!--<property name="stax.jar.name" value="C:\Documents and 
Settings\Ajith\.maven\repository\stax\jars\stax-api-1.0.jar"></property>-->

+            <property name="stax.available" value=""></property>

+            <property name="axis2.available" value=""></property>

+            <property name="jars.ok" value=""></property>

+            <property name="mappings.folder.name" value="Mapping"></property>

+            <property name="schemas.folder.name" value="schemas"></property>

+

+

+            <target name="move.files" depends="init">

+                <xsl:comment>first move the generated packages</xsl:comment>

+                <move>

+                    <xsl:attribute name="todir">${src}</xsl:attribute>

+                    <fileset >

+                        <xsl:attribute name="dir">${basedir}</xsl:attribute>

+                        <xsl:attribute name="includes"><xsl:value-of 
select="$package"></xsl:value-of>\**\</xsl:attribute>

+                    </fileset>

+

+                </move>

+                <xsl:comment>move the XBeans stuff to the temp</xsl:comment>

+                <move>

+                    <xsl:attribute name="todir">${temp}</xsl:attribute>

+                    <fileset >

+                        <xsl:attribute name="dir">${basedir}</xsl:attribute>

+                        <xsl:attribute 
name="includes">schemaorg_apache_xmlbeans\**\</xsl:attribute>

+                    </fileset>

+                </move>

+                <xsl:comment>move the rest of the stuff to the other 
folder</xsl:comment>

+                <move>

+                    <xsl:attribute name="todir">${other}</xsl:attribute>

+                    <fileset >

+                        <xsl:attribute name="dir">${basedir}</xsl:attribute>

+                        <xsl:attribute 
name="includes">${mappings.folder.name}\**\</xsl:attribute>

+                    </fileset>

+                </move>

+                <move>

+                    <xsl:attribute name="todir">${other}</xsl:attribute>

+                    <fileset >

+                        <xsl:attribute name="dir">${basedir}</xsl:attribute>

+                        <xsl:attribute 
name="includes">${schemas.folder.name}\**\</xsl:attribute>

+                    </fileset>

+                </move>

+

+            </target>

+

+            <target name="init">

+                <mkdir>

+                    <xsl:attribute name="dir">${src}</xsl:attribute>

+                </mkdir>

+                <mkdir>

+                    <xsl:attribute name="dir">${classes}</xsl:attribute>

+                </mkdir>

+                <mkdir>

+                    <xsl:attribute name="dir">${bin}</xsl:attribute>

+                </mkdir>

+                <mkdir>

+                    <xsl:attribute name="dir">${temp}</xsl:attribute>

+                </mkdir>

+            </target>

+

+            <target name="jar.xbeans" depends="move.files">

+                <!-- jar the  XMLbeans stuff to the bin folder-->

+                <jar>

+                    <xsl:attribute name="basedir">${temp}</xsl:attribute>

+                    <xsl:attribute 
name="destfile">${bin}\${xbeans.packaged.jar.name}</xsl:attribute>

+                </jar>

+            </target>

+

+            <target name="pre.compile.test">

+                <available classname="org.apache.xmlbeans.*">

+                    <xsl:attribute 
name="property">${xbeans.available}</xsl:attribute>

+                </available>

+                <available classname="javax.xml.stream.*" >

+                    <xsl:attribute 
name="property">${stax.available}</xsl:attribute>

+                </available>

+                <available classname="org.apache.axis.*">

+                    <xsl:attribute 
name="property">${axis2.available}</xsl:attribute>

+                </available>

+

+                <condition>

+                    <xsl:attribute name="property">${jars.ok}</xsl:attribute>

+                    <and>

+                        <isset>

+                            <xsl:attribute 
name="property">${xbeans.available}</xsl:attribute>

+                        </isset>

+                        <isset>

+                            <xsl:attribute 
name="property">${stax.available}</xsl:attribute>

+                        </isset>

+                        <isset>

+                            <xsl:attribute 
name="property">${axis2.available}</xsl:attribute>

+                        </isset>

+                    </and>

+                </condition>

+            </target>

+

+            <target name="compile.all"  depends="pre.compile.test">

+                <xsl:attribute name="if">${jars.ok}</xsl:attribute>

+                <javac>

+                    <xsl:attribute name="destdir">${classes}</xsl:attribute>

+                    <xsl:attribute name="srcdir">${src}</xsl:attribute>

+                    <classpath>

+                        <xsl:attribute 
name="location">${bin}\${xbeans.packaged.jar.name}</xsl:attribute>

+                    </classpath>

+                    <classpath >

+                        <xsl:attribute 
name="location">${java.class.path}</xsl:attribute>

+                    </classpath>

+                </javac>

+            </target>

+

+            <target name="echo.classpath.problem"  depends="pre.compile.test">

+                <xsl:attribute name="unless">${jars.ok}</xsl:attribute>

+                <echo message="The class path is not set right!"></echo>

+            </target>

+            <target name="jar.all" 
depends="compile.all,echo.classpath.problem" >

+                <xsl:attribute name="if">${jars.ok}</xsl:attribute>

+                <jar>

+                    <xsl:attribute name="basedir">${classes}</xsl:attribute>

+                    <xsl:attribute name="destfile">${bin}</xsl:attribute>

+                </jar>

+            </target>

+        </project>

+    </xsl:template>

+</xsl:stylesheet>


Modified: 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDL1ToWOMBuilder.java
 Thu Nov  3 04:30:28 2005
@@ -135,6 +135,8 @@
 
         WSDLReader reader =
                 WSDLFactory.newInstance().newWSDLReader();
+        reader.setFeature("javax.wsdl.importDocuments", true);
+
         File file = new File(uri);
         String baseURI = 
file.getParentFile()!=null?file.getParentFile().toURI().toString():null;
 
@@ -161,7 +163,7 @@
 
         WSDLReader reader =
                 WSDLFactory.newInstance().newWSDLReader();
-
+        reader.setFeature("javax.wsdl.importDocuments", true);
         Document doc;
         try {
             doc = XMLUtils.newDocument(in);

Modified: 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
URL: 
http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java?rev=330532&r1=330531&r2=330532&view=diff
==============================================================================
--- 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
 (original)
+++ 
webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
 Thu Nov  3 04:30:28 2005
@@ -131,6 +131,11 @@
         //                                                                     
                                                                //
         //////////////////////////////////////////////////////////////////////
 
+        //////////////////(0) process the imports ///////////////////////////
+        // There can be types that are imported. Check the imports and
+        // These schemas are needed for code generation
+        processImports(wsdl4JDefinition);
+
         //////////////////(1)First Copy the Types/////////////////////////////
         //Types may get changed inside the Operation pumping.
 
@@ -144,37 +149,6 @@
         }
 
 
-        // There can be types that are imported. Check the imports and
-        // These schemas are needed for code generation
-
-        Map wsdlImports = wsdl4JDefinition.getImports();
-
-        if (null != wsdlImports && !wsdlImports.isEmpty()){
-            Collection importsCollection = wsdlImports.values();
-            for (Iterator iterator = importsCollection.iterator(); 
iterator.hasNext();) {
-                Vector values = (Vector)iterator.next();
-                for (int i = 0; i < values.size(); i++) {
-                    Import wsdlImport = (Import)values.elementAt(i);
-
-                    if (wsdlImport.getDefinition()!=null){
-                        Definition importedDef = wsdlImport.getDefinition();
-
-                        if (wsdlTypes==null){
-                            wsdlTypes = 
this.wsdlComponentFactory.createTypes();
-                        }
-                        //add the imported types
-                        this.copyExtensibleElements(importedDef.getTypes().
-                                getExtensibilityElements(),
-                                wsdlTypes, null);
-                        this.womDefinition.setTypes(wsdlTypes);
-                    }
-                }
-
-            }
-        }
-
-
-
         ///////////////////(2)Copy the Interfaces///////////////////////////
         //copy the Interfaces: Get the PortTypes from WSDL4J parse OM and
         // copy it to the
@@ -272,6 +246,49 @@
         }
     }
 
+
+    private void processImports(Definition wsdl4JDefinition){
+        Map wsdlImports = wsdl4JDefinition.getImports();
+
+        if (null != wsdlImports && !wsdlImports.isEmpty()){
+            Collection importsCollection = wsdlImports.values();
+            for (Iterator iterator = importsCollection.iterator(); 
iterator.hasNext();) {
+                Vector values = (Vector)iterator.next();
+                for (int i = 0; i < values.size(); i++) {
+                    Import wsdlImport = (Import)values.elementAt(i);
+
+                    if (wsdlImport.getDefinition()!=null){
+                        Definition importedDef = wsdlImport.getDefinition();
+                        if (importedDef!=null){
+                            processImports(importedDef);
+
+                            //copy types
+                            Types t = importedDef.getTypes();
+                            List typesList = t.getExtensibilityElements();
+                            for (int j = 0; j < typesList.size(); j++) {
+                                
wsdl4JDefinition.getTypes().addExtensibilityElement(
+                                        
(ExtensibilityElement)typesList.get(j));
+
+                            }
+
+                            //add messages
+                            Map messagesMap = importedDef.getMessages();
+                            wsdl4JDefinition.getMessages().putAll(messagesMap);
+
+                            //add portypes
+                            Map porttypeMap = importedDef.getPortTypes();
+                            
wsdl4JDefinition.getPortTypes().putAll(porttypeMap);
+
+                        }
+
+                    }
+                }
+            }
+        }
+    }
+
+
+
     /**
      *
 
@@ -306,6 +323,7 @@
      */
     private void populateBindings(WSDLBinding wsdlBinding,
                                   Binding wsdl4JBinding, Definition 
wsdl4jDefinition) {
+       
         //Copy attributes
         wsdlBinding.setName(wsdl4JBinding.getQName());
         QName interfaceName = wsdl4JBinding.getPortType().getQName();
@@ -397,9 +415,9 @@
         Input wsdl4jInputMessage = wsdl4jOperation.getInput();
         QName wrappedInputName = wsdlOperation.getName();
         QName wrappedOutputName = new QName(
-                               wrappedInputName.getNamespaceURI(),
-                               wrappedInputName.getLocalPart()+ "Response",
-                               wrappedInputName.getPrefix());
+                wrappedInputName.getNamespaceURI(),
+                wrappedInputName.getLocalPart()+ "Response",
+                wrappedInputName.getPrefix());
 
         if (null != wsdl4jInputMessage) {
             MessageReference wsdlInputMessage = this.wsdlComponentFactory
@@ -559,8 +577,8 @@
                 //the DOMlevel2 documentation states that namespaces need to
                 //declared like this
                 schemaElement.setAttributeNS("http://www.w3.org/2000/xmlns/";,
-                                              XMLNS_AXIS2WRAPPED,
-                                              targetNamespaceUri);
+                        XMLNS_AXIS2WRAPPED,
+                        targetNamespaceUri);
 
                 
schemaElement.setAttribute(XSD_TARGETNAMESPACE,targetNamespaceUri);
                 
//schemaElement.setAttribute("xmlns:"+XMLSCHEMA_NAMESPACE_PREFIX,XMLSCHEMA_NAMESPACE_URI);
@@ -622,7 +640,7 @@
                         outerName.getLocalPart());
                 newElement.setAttribute(WSDLPump.XSD_TYPE,
                         AXIS2WRAPPED +":"+//whats the prefix to put here!!!
-                        wsdl4jMessage.getQName().getLocalPart());
+                                wsdl4jMessage.getQName().getLocalPart());
                 schemaElement.appendChild(newElement);
 
                 //Now since  a new type is created augmenting the parts add 
the QName


Reply via email to