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 aj...@apache.org on 2005/08/23 16:19:25 UTC

svn commit: r239412 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache: axis2/wsdl/builder/wsdl4j/ axis2/wsdl/codegen/emitter/ axis2/wsdl/codegen/extension/ wsdl/extensions/ wsdl/impl/

Author: ajith
Date: Tue Aug 23 07:18:38 2005
New Revision: 239412

URL: http://svn.apache.org/viewcvs?rev=239412&view=rev
Log:
Modified the code generator to cater for the interface generation issue.
1. Modified the emitters
2. modified the binding builder and the rest of the extensions to fix several bugs
3. Updated the WSDLPump.java to fix a hidden bug caused when the WSDL contains both types in itself and the imports
4. Updated the XMLBeansExtension.java to prevent the duplicate additions of schemas.

Note - The test cases are passing but some weird WSDL's are still causing problems. Refer to the Jira Issue

Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.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/AxisBindingBuilder.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLDescriptionImpl.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/builder/wsdl4j/WSDLPump.java Tue Aug 23 07:18:38 2005
@@ -48,14 +48,14 @@
 public class WSDLPump {
 
     private static final String XSD_TYPE = "type";
-	private static final String XSD_SEQUENCE = "sequence";
-	private static final String XSD_NAME = "name";
-	private static final String XSD_COMPLEXTYPE = "complexType";
-	private static final String XSD_TARGETNAMESPACE = "targetNamespace";
-	private static final String XMLNS_AXIS2WRAPPED = "xmlns:axis2wrapped";
-	private static final String NAMESPACE_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema";
-	private static final String XSD_ELEMENT = "element";
-	private static final String BOUND_INTERFACE_NAME = "BoundInterface";
+    private static final String XSD_SEQUENCE = "sequence";
+    private static final String XSD_NAME = "name";
+    private static final String XSD_COMPLEXTYPE = "complexType";
+    private static final String XSD_TARGETNAMESPACE = "targetNamespace";
+    private static final String XMLNS_AXIS2WRAPPED = "xmlns:axis2wrapped";
+    private static final String NAMESPACE_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema";
+    private static final String XSD_ELEMENT = "element";
+    private static final String BOUND_INTERFACE_NAME = "BoundInterface";
 
     private WSDLDescription womDefinition;
 
@@ -115,8 +115,9 @@
         //Types may get changed inside the Operation pumping.
 
         Types wsdl4jTypes = wsdl4JDefinition.getTypes();
+        WSDLTypes wsdlTypes = null;
         if (null != wsdl4jTypes) {
-            WSDLTypes wsdlTypes = this.wsdlComponentFactory.createTypes();
+            wsdlTypes = this.wsdlComponentFactory.createTypes();
             this.copyExtensibleElements(wsdl4jTypes.getExtensibilityElements(),
                     wsdlTypes);
             this.womDefinition.setTypes(wsdlTypes);
@@ -144,8 +145,11 @@
 
                     if (wsdlImport.getDefinition()!=null){
                         Definition importedDef = wsdlImport.getDefinition();
+
+                        if (wsdlTypes==null){
+                            wsdlTypes = this.wsdlComponentFactory.createTypes();
+                        }
                         //add the imported types
-                        WSDLTypes wsdlTypes = this.wsdlComponentFactory.createTypes();
                         this.copyExtensibleElements(importedDef.getTypes().
                                 getExtensibilityElements(),
                                 wsdlTypes);
@@ -323,8 +327,6 @@
                 }
 
             }
-        }else{
-            return;
         }
     }
 
@@ -455,7 +457,7 @@
                 //out of it and add it to the schema.
                 Element schemaElement = null;
                 WSDLTypes types = womDefinition.getTypes();
-                
+
                 //If types is null create a new one to be used for multipart 
                 //resolution if any.
                 if (null == types) {
@@ -476,8 +478,8 @@
                     types.addExtensibilityElement(typesElement);
                     this.womDefinition.setTypes(types);
                 }
-                
-                
+
+
                 //
                 Iterator schemaEIIterator = types.getExtensibilityElements()
                         .iterator();
@@ -496,7 +498,7 @@
                 Element newType = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_COMPLEXTYPE);
                 newType.setAttribute(WSDLPump.XSD_NAME, name);
 
-                
+
                 Element cmplxContent = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_SEQUENCE);
                 Element child;
                 Element relaventElementInSchemaReferedByPart = null;
@@ -510,38 +512,38 @@
 
                     NodeList allSchemaElements = schemaElement.getChildNodes();
                     for(int idx = 0; idx < allSchemaElements.getLength(); idx++){
-                    	if(allSchemaElements.item(idx).getNodeType() == Node.ELEMENT_NODE && 
-                    			allSchemaElements.item(idx).getLocalName().equals(WSDLPump.XSD_ELEMENT)
-                    			&& elementName.getLocalPart().equals(((Element)allSchemaElements.item(idx)).getAttribute(WSDLPump.XSD_NAME))){
-                    		relaventElementInSchemaReferedByPart = (Element)allSchemaElements.item(idx);
-                    		break;
-                    	}
+                        if(allSchemaElements.item(idx).getNodeType() == Node.ELEMENT_NODE &&
+                                allSchemaElements.item(idx).getLocalName().equals(WSDLPump.XSD_ELEMENT)
+                                && elementName.getLocalPart().equals(((Element)allSchemaElements.item(idx)).getAttribute(WSDLPump.XSD_NAME))){
+                            relaventElementInSchemaReferedByPart = (Element)allSchemaElements.item(idx);
+                            break;
+                        }
                     }
                     child = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_ELEMENT);
                     child.setAttribute(WSDLPump.XSD_NAME, elementName.getLocalPart());
                     if(null != relaventElementInSchemaReferedByPart){
-                    
-                    	
-                    	child.setAttribute(WSDLPump.XSD_TYPE, 
-                    			relaventElementInSchemaReferedByPart.getAttribute(WSDLPump.XSD_TYPE));
+
+
+                        child.setAttribute(WSDLPump.XSD_TYPE,
+                                relaventElementInSchemaReferedByPart.getAttribute(WSDLPump.XSD_TYPE));
                     }else{
-                    	child.setAttribute(WSDLPump.XSD_TYPE, elementName.getLocalPart());
+                        child.setAttribute(WSDLPump.XSD_TYPE, elementName.getLocalPart());
                     }
                     cmplxContent.appendChild(child);
-                    
+
                 }
 
 
                 newType.appendChild(cmplxContent);
 
                 schemaElement.appendChild(newType);
-                
-                
+
+
                 Element newElement = doc.createElementNS(WSDLPump.NAMESPACE_XMLSCHEMA, WSDLPump.XSD_ELEMENT);
                 newElement.setAttribute(WSDLPump.XSD_NAME,
                         wsdl4jMessage.getQName().getLocalPart());
                 newElement.setAttribute(WSDLPump.XSD_TYPE,
-                		"axis2wrapped:"+wsdl4jMessage.getQName().getLocalPart());
+                        "axis2wrapped:"+wsdl4jMessage.getQName().getLocalPart());
                 schemaElement.appendChild(newElement);
                 //Now since  a new type is created augmenting the parts add the QName
                 //of the newly created type as the messageReference's name.
@@ -627,8 +629,8 @@
         wsdlEndpoint.setBinding(
                 this.womDefinition.getBinding(
                         wsdl4jPort
-                .getBinding()
-                .getQName()));
+                                .getBinding()
+                                .getQName()));
 
     }
 
@@ -671,9 +673,9 @@
         newBoundInterface.setName(
                 new QName(service.getNamespace(),
                         service
-                .getName()
-                .getLocalPart()
-                + BOUND_INTERFACE_NAME));
+                                .getName()
+                                .getLocalPart()
+                                + BOUND_INTERFACE_NAME));
         Iterator interfaceIterator = this.womDefinition.getWsdlInterfaces()
                 .values().iterator();
         while (interfaceIterator.hasNext()) {

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Tue Aug 23 07:18:38 2005
@@ -7,8 +7,9 @@
 import org.apache.axis2.wsdl.databinding.TypeMapper;
 import org.apache.wsdl.*;
 import org.apache.wsdl.extensions.ExtensionConstants;
-import org.apache.wsdl.extensions.SOAPBody;
 import org.apache.wsdl.extensions.SOAPOperation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -53,10 +54,13 @@
 
 
 public abstract class MultiLanguageClientEmitter implements Emitter {
+
+    private Log log = LogFactory.getLog(getClass());
+
     /*
-     *  Important! These constants are used in some places in the templates. Care should
-     *  be taken when changing them
-     */
+    *  Important! These constants are used in some places in the templates. Care should
+    *  be taken when changing them
+    */
     private static final String CALL_BACK_HANDLER_SUFFIX = "CallbackHandler";
     private static final String STUB_SUFFIX = "Stub";
     private static final String TEST_SUFFIX = "Test";
@@ -91,7 +95,60 @@
     public void setCodeGenConfiguration(CodeGenConfiguration configuration) {
         this.configuration = configuration;
     }
+    /**
+     * @see org.apache.axis2.wsdl.codegen.emitter.Emitter#emitSkeleton()
+     */
+    public void emitSkeleton() throws CodeGenerationException {
+        try {
+            //get the binding
+            WSDLDescription wom = this.configuration.getWom();
+            Map interfaces = wom.getWsdlInterfaces();
 
+            //loop through the wsdlInterfaces to generate the interface code
+            //theoretically the interface should be the base for the interfaces
+            Collection interfaceCollection =interfaces.values();
+            for (Iterator iterator = interfaceCollection.iterator(); iterator.hasNext();) {
+                WSDLInterface axisInteface = (WSDLInterface) iterator.next();
+                //write skeleton
+                writeSkeleton(axisInteface);
+                //write interface implementations
+                writeServiceXml(axisInteface);
+            }
+
+            Map bindings = wom.getBindings();
+            if (bindings==null || bindings.isEmpty()){
+                //We may need a flag in the config to force code generation with the binding
+                //if so the following check needs to be uncommented. For now log the situation
+                //throw new CodeGenerationException("Binding needs to be present!");
+                log.info("No binding is present.The follwing items will not be generated");
+                log.info("1. Message Receiver");
+
+            }else{
+                WSDLBinding axisBinding;
+                Collection bindingCollection = bindings.values();
+                for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+                    axisBinding  =  (WSDLBinding)iterator.next();
+
+                    //write the local test classes
+                    //writeLocalTestClasses(axisBinding);
+                    //write a dummy implementation call for the tests to run.
+                    //writeTestSkeletonImpl(axisBinding);
+                    //write a testservice.xml that will load the dummy skeleton impl for testing
+                    //writeTestServiceXML(axisBinding);
+                    //write a MessageReceiver for this particular service.
+                    writeMessageReceiver(axisBinding);
+                }
+            }
+
+            // Call the emit stub method to generate the client side too
+            // Do we need to enforce this here ?????
+            // Perhaps we can introduce a flag to determine this!
+            emitStub();
+
+        } catch (Exception e) {
+            throw new CodeGenerationException(e);
+        }
+    }
     /**
      * @see org.apache.axis2.wsdl.codegen.emitter.Emitter#emitStub()
      */
@@ -99,47 +156,67 @@
         try {
             //get the binding
             WSDLDescription wom = this.configuration.getWom();
-            Map bindings = wom.getBindings();
-            WSDLBinding axisBinding = null;
-            WSDLService axisService = null;
-            if (bindings==null){
-                throw new CodeGenerationException("Binding needs to be present!");
+            Map interfaces = wom.getWsdlInterfaces();
+
+            //loop through the wsdlInterfaces to generate the interface code
+            //theoretically the interface should be the base for the interfaces
+            Collection interfaceCollection =interfaces.values();
+            for (Iterator iterator = interfaceCollection.iterator(); iterator.hasNext();) {
+                //Write the interfaces
+                writeInterface((WSDLInterface)iterator.next());
             }
 
-            Collection bindingCollection = bindings.values();
-            for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
-                axisBinding  =  (WSDLBinding)iterator.next();
-
-                //write interfaces
-                Map services = wom.getServices();
-                if (!services.isEmpty()) {
-                    if (services.size() == 1) {
-                        axisService = (WSDLService) services.values().toArray()[0];
-                    } else {
-                        throw new UnsupportedOperationException(
-                                "Single service WSDL files only");
-                    }
+            Map bindings = wom.getBindings();
+            if (bindings==null || bindings.isEmpty()){
+                //We may need a flag in the config to force code generation with the binding
+                //if so the following check needs to be uncommented. For now log the situation
+                //throw new CodeGenerationException("Binding needs to be present!");
+                log.info("No binding is present.The follwing items will not be generated");
+                log.info("1. Stub");
+                log.info("2. CallbackHandler");
+                log.info("3. Test Classes");
+                log.info("3. Databinding Supporters");
+            }else{
+                WSDLBinding axisBinding ;
+                WSDLService axisService = null;
+                Collection bindingCollection = bindings.values();
+                for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+                    axisBinding  =  (WSDLBinding)iterator.next();
+                    //Check the service
+                    axisService = checkService(wom, axisService);
+
+                    //write interface implementations
+                    writeInterfaceImplementation(axisBinding, axisService);
+                    //write the call back handlers
+                    writeCallBackHandlers(axisBinding);
+                    //write the test classes
+                    writeTestClasses(axisBinding);
+                    //write the databinding supporters
+                    writeDatabindingSupporters(axisBinding);
+                    //write a dummy implementation call for the tests to run.
+                    //writeTestSkeletonImpl(axisBinding);
+                    //write a testservice.xml that will load the dummy skeleton impl for testing
+                    //writeTestServiceXML(axisBinding);
                 }
-                //
-                writeInterface(axisBinding);
-                //write interface implementations
-                writeInterfaceImplementation(axisBinding, axisService);
-                //write the call back handlers
-                writeCallBackHandlers(axisBinding);
-                //write the test classes
-                writeTestClasses(axisBinding);
-                //write the databinding supporters
-                writeDatabindingSupporters(axisBinding);
-                //write a dummy implementation call for the tests to run.
-                //writeTestSkeletonImpl(axisBinding);
-                //write a testservice.xml that will load the dummy skeleton impl for testing
-                //writeTestServiceXML(axisBinding);
             }
         } catch (Exception e) {
             throw new CodeGenerationException(e);
         }
     }
 
+    private WSDLService checkService(WSDLDescription wom, WSDLService axisService) {
+        Map services = wom.getServices();
+        if (!services.isEmpty()) {
+            if (services.size() == 1) {
+                axisService = (WSDLService) services.values().toArray()[0];
+            } else {
+                throw new UnsupportedOperationException(
+                        "Single service WSDL files only");
+            }
+        }
+        return axisService;
+    }
+
 
     protected void writeTestSkeletonImpl(WSDLBinding binding) throws Exception {
         if (configuration.isWriteTestCase()) {
@@ -207,11 +284,11 @@
     /**
      * Writes the interfaces
      *
-     * @param axisBinding
+     * @param axisInterface
      * @throws Exception
      */
-    protected void writeInterface(WSDLBinding axisBinding) throws Exception {
-        Document interfaceModel = createDOMDocumentForInterface(axisBinding);
+    protected void writeInterface(WSDLInterface axisInterface) throws Exception {
+        Document interfaceModel = createDOMDocumentForInterface(axisInterface);
         InterfaceWriter interfaceWriter =
                 new InterfaceWriter(this.configuration.getOutputLocation(),
                         this.configuration.getOutputLanguage());
@@ -221,13 +298,13 @@
     /**
      * Writes the skeleton
      *
-     * @param axisBinding
+     * @param axisInteface
      * @throws Exception
      */
-    protected void writeSkeleton(WSDLBinding axisBinding) throws Exception {
+    protected void writeSkeleton(WSDLInterface axisInteface) throws Exception {
 
         //Note -  One can generate the skeleton using the interface XML
-        Document skeletonModel = createDOMDocumentForSkeleton(axisBinding);
+        Document skeletonModel = createDOMDocumentForSkeleton(axisInteface);
         ClassWriter skeletonWriter = new SkeletonWriter(
                 this.configuration.getOutputLocation(),
                 this.configuration.getOutputLanguage());
@@ -260,11 +337,11 @@
 
     }
 
-    protected void writeTestServiceXML(WSDLBinding axisBinding) throws Exception {
+    protected void writeTestServiceXML(WSDLInterface axisInterface) throws Exception {
         if (this.configuration.isWriteTestCase()) {
             //Note -  One can generate the service xml using the interface XML
             Document skeletonModel = createDOMDocumentForServiceXML(
-                    axisBinding, true);
+                    axisInterface, true);
             TestServiceXMLWriter testServiceXmlWriter = new TestServiceXMLWriter(
                     this.configuration.getOutputLocation(),
                     this.configuration.getOutputLanguage());
@@ -275,13 +352,13 @@
     /**
      * Writes the skeleton
      *
-     * @param axisBinding
+     * @param axisInterface
      * @throws Exception
      */
-    protected void writeServiceXml(WSDLBinding axisBinding) throws Exception {
+    protected void writeServiceXml(WSDLInterface axisInterface) throws Exception {
         if (this.configuration.isGenerateDeployementDescriptor()) {
             Document skeletonModel = createDOMDocumentForServiceXML(
-                    axisBinding, false);
+                    axisInterface, false);
             ClassWriter serviceXmlWriter = new ServiceXMLWriter(
                     this.configuration.getOutputLocation(),
                     this.configuration.getOutputLanguage());
@@ -368,47 +445,7 @@
                 new ByteArrayInputStream(memoryStream.toByteArray()));
     }
 
-    /**
-     * @see org.apache.axis2.wsdl.codegen.emitter.Emitter#emitSkeleton()
-     */
-    public void emitSkeleton() throws CodeGenerationException {
-        try {
-            //get the binding
-            WSDLDescription wom = this.configuration.getWom();
-            Map bindings = wom.getBindings();
-            WSDLBinding axisBinding = null;
-
-            if (bindings==null){
-                throw new CodeGenerationException("Binding needs to be present!");
-            }
 
-            Collection bindingCollection = bindings.values();
-
-            for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
-                axisBinding  =  (WSDLBinding)iterator.next();
-                //write interfaces
-                writeSkeleton(axisBinding);
-                //write interface implementations
-                writeServiceXml(axisBinding);
-                //write the local test classes
-//               writeLocalTestClasses(axisBinding);
-                //write a dummy implementation call for the tests to run.
-                //writeTestSkeletonImpl(axisBinding);
-                //write a testservice.xml that will load the dummy skeleton impl for testing
-                //writeTestServiceXML(axisBinding);
-                //write a MessageReceiver for this particular service.
-                writeMessageReceiver(axisBinding);
-            }
-            // Call the emit stub method to generate the client side too
-            // Do we need to enforce this here ?????
-            // Perhaps we can introduce a flag to determine this!
-            emitStub();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new CodeGenerationException(e);
-        }
-    }
 
     protected Document createDocumentForTestSkeletonImpl(
             WSDLBinding binding) {
@@ -432,7 +469,7 @@
         addAttribute(doc,
                 "name",
                 boundInterface.getName().getLocalPart() +
-                TEST_SERVICE_CLASS_NAME_SUFFIX,
+                        TEST_SERVICE_CLASS_NAME_SUFFIX,
                 rootElement);
         addAttribute(doc,
                 "namespace",
@@ -457,7 +494,6 @@
      * Generating the callbacks
      *
      * @param binding
-     * @return
      */
     protected Document createDOMDocumentForCallbackHandler(
             WSDLBinding binding) {
@@ -471,7 +507,7 @@
         addAttribute(doc,
                 "name",
                 boundInterface.getName().getLocalPart() +
-                CALL_BACK_HANDLER_SUFFIX,
+                        CALL_BACK_HANDLER_SUFFIX,
                 rootElement);
         addAttribute(doc,
                 "namespace",
@@ -491,7 +527,6 @@
      *
      * @param doc
      * @param operation
-     * @return
      */
     protected Element getInputElement(Document doc,
                                       WSDLOperation operation) {
@@ -528,7 +563,6 @@
      *
      * @param doc
      * @param operation
-     * @return
      */
     protected Element getOutputElement(Document doc,
                                        WSDLOperation operation) {
@@ -545,8 +579,8 @@
                                           WSDLOperation operation) {
         Element param = doc.createElement("param");
         MessageReference outputMessage = operation.getOutputMessage();
-        String typeMappingStr = null;
-        String parameterName = null;
+        String typeMappingStr;
+        String parameterName;
 
         if (outputMessage!=null){
             parameterName =  this.mapper.getParameterName(
@@ -559,8 +593,8 @@
             parameterName = "" ;
             typeMappingStr = "";
         }
-          addAttribute(doc,"name",parameterName,param);
-          addAttribute(doc,"type", typeMappingStr, param);
+        addAttribute(doc,"name",parameterName,param);
+        addAttribute(doc,"type", typeMappingStr, param);
 
         return param;
     }
@@ -568,15 +602,13 @@
     /**
      * Todo Finish this
      *
-     * @return
      */
     protected Document createDOMDocumentForBean() {
         return null;
     }
 
-    protected Document createDOMDocumentForServiceXML(WSDLBinding binding,
+    protected Document createDOMDocumentForServiceXML(WSDLInterface boundInterface,
                                                       boolean forTesting) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
 
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("interface");
@@ -643,7 +675,7 @@
         addAttribute(doc,
                 "dbsupportpackage",
                 configuration.getPackageName() +
-                DATABINDING_PACKAGE_NAME_SUFFIX,
+                        DATABINDING_PACKAGE_NAME_SUFFIX,
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(boundInterface, doc, rootElement, binding);
@@ -656,11 +688,9 @@
     /**
      * Creates the DOM tree for the interface creation
      *
-     * @param binding
-     * @return
+     * @param wsdlInterface
      */
-    protected Document createDOMDocumentForInterface(WSDLBinding binding) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
+    protected Document createDOMDocumentForInterface(WSDLInterface wsdlInterface) {
 
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("interface");
@@ -670,24 +700,23 @@
                 rootElement);
         addAttribute(doc,
                 "name",
-                boundInterface.getName().getLocalPart(),
+                wsdlInterface.getName().getLocalPart(),
                 rootElement);
         addAttribute(doc,
                 "callbackname",
-                boundInterface.getName().getLocalPart() +
-                CALL_BACK_HANDLER_SUFFIX,
+                wsdlInterface.getName().getLocalPart() +
+                        CALL_BACK_HANDLER_SUFFIX,
                 rootElement);
         fillSyncAttributes(doc, rootElement);
-        loadOperations(boundInterface, doc, rootElement);
+        loadOperations(wsdlInterface, doc, rootElement);
         doc.appendChild(rootElement);
         return doc;
 
     }
 
-    protected Document createDOMDocumentForSkeleton(WSDLBinding binding) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
+    protected Document createDOMDocumentForSkeleton(WSDLInterface boundInterface) {
 
-        Document doc = getEmptyDocument();;
+        Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("interface");
         addAttribute(doc,
                 "package",
@@ -700,7 +729,7 @@
         addAttribute(doc,
                 "callbackname",
                 boundInterface.getName().getLocalPart() +
-                CALL_BACK_HANDLER_SUFFIX,
+                        CALL_BACK_HANDLER_SUFFIX,
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(boundInterface, doc, rootElement);
@@ -812,7 +841,7 @@
         addAttribute(doc,
                 "dbsupportpackage",
                 configuration.getPackageName() +
-                DATABINDING_PACKAGE_NAME_SUFFIX,
+                        DATABINDING_PACKAGE_NAME_SUFFIX,
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(boundInterface, doc, rootElement);
@@ -855,8 +884,8 @@
         addAttribute(doc,
                 "address",
                 "http://localhost:" + Constants.TEST_PORT + "/services/" +
-                boundInterface.getName().getLocalPart() +
-                TEST_SERVICE_CLASS_NAME_SUFFIX,
+                        boundInterface.getName().getLocalPart() +
+                        TEST_SERVICE_CLASS_NAME_SUFFIX,
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(boundInterface, doc, rootElement);
@@ -873,7 +902,7 @@
         addAttribute(doc,
                 "package",
                 configuration.getPackageName() +
-                DATABINDING_PACKAGE_NAME_SUFFIX,
+                        DATABINDING_PACKAGE_NAME_SUFFIX,
                 rootElement);
         String localPart = operation.getName().getLocalPart();
         addAttribute(doc,
@@ -905,7 +934,6 @@
      *
      * @param binding
      * @param service
-     * @return
      */
     protected Document createDOMDocumentForInterfaceImplementation(
             WSDLBinding binding, WSDLService service) {
@@ -933,7 +961,7 @@
         addAttribute(doc,
                 "dbsupportpackage",
                 configuration.getPackageName() +
-                DATABINDING_PACKAGE_NAME_SUFFIX,
+                        DATABINDING_PACKAGE_NAME_SUFFIX,
                 rootElement);
         addEndpoints(doc, rootElement, endpoints);
         fillSyncAttributes(doc, rootElement);
@@ -983,19 +1011,6 @@
         return word.replaceAll("\\W", "_");
     }
 
-    protected void foo(WSDLBindingOperation bindingOp) {
-        Iterator extIterator = bindingOp.getInput().getExtensibilityElements()
-                .iterator();
-        while (extIterator.hasNext()) {
-            WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
-            if (element.getType().equals(ExtensionConstants.SOAP_BODY)) {
-                if (WSDLConstants.WSDL_USE_ENCODED.equals(
-                        ((SOAPBody) element).getUse())) {
-                    throw new RuntimeException(
-                            "The use 'encoded' is not supported!");
-                }
-            }
-        }
-    }
+
 }
 

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=239412&r1=239411&r2=239412&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 Tue Aug 23 07:18:38 2005
@@ -17,11 +17,13 @@
 package org.apache.axis2.wsdl.codegen.extension;
 
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @author chathura@opensource.lk
  */
 public abstract class AbstractCodeGenerationExtension implements CodeGenExtension {
-
+    protected Log log = LogFactory.getLog(this.getClass());
     protected CodeGenConfiguration configuration;
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java Tue Aug 23 07:18:38 2005
@@ -21,8 +21,12 @@
 
 import javax.xml.namespace.QName;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Vector;
 
 /**
+ * The purpose of this extension is to build the bindings. bindings however may not be present
  * @author chathura@opensource.lk
  */
 public class AxisBindingBuilder extends AbstractCodeGenerationExtension implements CodeGenExtension {
@@ -43,29 +47,47 @@
 
     public void engage() {
         WSDLDescription wom = this.configuration.getWom();
-        WSDLBinding binding = wom.getFirstBinding();
+        Map bindingMap = wom.getBindings();
+        Vector bindingVector = new Vector();
 
-        WSDLBinding newBinding = wom.createBinding();
-        newBinding.setName(AXIS_BINDING_QNAME);
+        if (bindingMap==null || bindingMap.isEmpty()) {
+            log.info(" bindings are not present in the original document");
+            //just fall through
+        }else{
+            Collection bindingCollection = bindingMap.values();
+            for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+
+                WSDLBinding binding = (WSDLBinding)iterator.next();
+
+                WSDLBinding newBinding = wom.createBinding();
+                newBinding.setName(AXIS_BINDING_QNAME);
+
+                WSDLInterface boundInterface = binding.getBoundInterface();
+                newBinding.setBoundInterface(boundInterface);
+
+                newBinding.setBindingFaults(binding.getBindingFaults());
+                newBinding.setBindingOperations(binding.getBindingOperations());
+                Iterator elementIterator = binding.getExtensibilityElements().iterator();
+                while (elementIterator.hasNext()) {
+                    newBinding.addExtensibilityElement(
+                            (WSDLExtensibilityElement) elementIterator.next());
+                }
+
+                Iterator attributeIterator = binding.getExtensibilityAttributes()
+                        .iterator();
+                while (attributeIterator.hasNext()) {
+                    newBinding.addExtensibleAttributes(
+                            (WSDLExtensibilityAttribute) attributeIterator.next());
+                }
+                bindingVector.add(newBinding);
+
+            }
+            //drop all the bindings and add the new ones
+            wom.getBindings().clear();
+            for (int i = 0; i < bindingVector.size(); i++) {
+                wom.addBinding ((WSDLBinding) bindingVector.get(i));
+            }
 
-        WSDLInterface boundInterface = binding.getBoundInterface();
-        newBinding.setBoundInterface(boundInterface);
-
-        newBinding.setBindingFaults(binding.getBindingFaults());
-        newBinding.setBindingOperations(binding.getBindingOperations());
-        Iterator elementIterator = binding.getExtensibilityElements().iterator();
-        while (elementIterator.hasNext()) {
-            newBinding.addExtensibilityElement(
-                    (WSDLExtensibilityElement) elementIterator.next());
-        }
-
-        Iterator attributeIterator = binding.getExtensibilityAttributes()
-                .iterator();
-        while (attributeIterator.hasNext()) {
-            newBinding.addExtensibleAttributes(
-                    (WSDLExtensibilityAttribute) attributeIterator.next());
         }
-
-        wom.addBinding(newBinding);
     }
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java Tue Aug 23 07:18:38 2005
@@ -2,6 +2,7 @@
 
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
 import org.apache.axis2.wsdl.databinding.TypeMapper;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 
@@ -21,6 +22,7 @@
  * limitations under the License.
  *
  *  The function of this class is to fill the default information if it's not already filled
+ *  Note - This extension is meant to be the last of the extensions
  */
 public class DefaultDatabindingExtension extends AbstractCodeGenerationExtension {
     private CodeGenConfiguration configuration;
@@ -30,8 +32,14 @@
 
     public void engage() throws CodeGenerationException {
         TypeMapper mappper = configuration.getTypeMapper();
-        if (mappper==null){
+        if (configuration.getDatabindingType() == XSLTConstants.DataBindingTypes.NONE){
             configuration.setTypeMapper(new DefaultTypeMapper());
+        }else{
+            if (mappper==null){
+                //this shouldn't happen
+                throw new CodeGenerationException("No proper databinding has taken place");
+            }
         }
+
     }
 }

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=239412&r1=239411&r2=239412&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 Tue Aug 23 07:18:38 2005
@@ -4,16 +4,14 @@
 import org.apache.axis2.wsdl.codegen.XSLTConstants;
 import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
 import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
-import org.apache.wsdl.WSDLExtensibilityElement;
-import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.*;
 import org.apache.wsdl.extensions.ExtensionConstants;
 import org.apache.wsdl.extensions.Schema;
+import org.apache.wsdl.extensions.SOAPBody;
 import org.apache.xmlbeans.*;
 
 import java.io.*;
-import java.util.List;
-import java.util.Stack;
-import java.util.Vector;
+import java.util.*;
 
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
@@ -48,12 +46,18 @@
             return;
         }
 
+        //check the comptibilty
+        checkCompatibility();
+
         //test whether the TCCL has the Xbeans classes
         //ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
 
         try {
+            //get the types from the types section
             WSDLTypes typesList = configuration.getWom().getTypes();
+
+            //check for the imported types
             if (typesList == null) {
                 //there are no types to be code generated
                 //However if the type mapper is left empty it will be a problem for the other
@@ -63,13 +67,18 @@
             }
 
             List typesArray = typesList.getExtensibilityElements();
-            WSDLExtensibilityElement extensiblityElt = null;
-            SchemaTypeSystem sts  = null;
-          
-            Vector xmlObjectsVector = new Vector();
+            WSDLExtensibilityElement extensiblityElt;
+            SchemaTypeSystem sts;
+            Vector schemabaseURIList=new Vector();
+            Vector xmlObjectsVector= new Vector();
+            String schemaBaseURI ;
+
+            //create the type mapper
+            JavaTypeMapper mapper = new JavaTypeMapper();
+
             for (int i = 0; i < typesArray.size(); i++) {
                 extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
-                Schema schema = null;
+                Schema schema;
 
                 if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
                     schema = (Schema) extensiblityElt;
@@ -80,31 +89,35 @@
                     Stack importedSchemaStack = schema.getImportedSchemaStack();
                     //compile these schemas
                     while (!importedSchemaStack.isEmpty()){
-                        xmlObjectsVector.add(
-                                XmlObject.Factory.parse(
-                                        ((javax.wsdl.extensions.schema.Schema)importedSchemaStack.pop()).getElement()
-                                        ,options));
+                        javax.wsdl.extensions.schema.Schema tempSchema = (javax.wsdl.extensions.schema.Schema) importedSchemaStack.pop();
+                        schemaBaseURI = tempSchema.getDocumentBaseURI();
+                        //prevent the readdition of schama's that has already being added
+                        if (!schemabaseURIList.contains(schemaBaseURI)){
+                            schemabaseURIList.add(schemaBaseURI);
+                            xmlObjectsVector.add(
+                                    XmlObject.Factory.parse(
+                                            tempSchema.getElement()
+                                            ,options));
+                        }
+
                     }
+
+
                 }
 
             }
-
             sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
                     convertToXMLObjectArray(xmlObjectsVector),
                     new BindingConfig(), XmlBeans.getContextTypeLoader(),
                     new Axis2Filer(),
                     null);
-
-            //create the type mapper
-            JavaTypeMapper mapper = new JavaTypeMapper();
             SchemaType[] schemaType = sts.documentTypes();
             SchemaType type;
-            for (int i = 0; i < schemaType.length; i++) {
-                type = schemaType[i];
+            for (int j = 0; j < schemaType.length; j++) {
+                type = schemaType[j];
                 mapper.addTypeMapping(type.getDocumentElementName(),
                         type.getFullJavaName());
             }
-
             //set the type mapper to the config
             configuration.setTypeMapper(mapper);
         } catch (Exception e) {
@@ -113,6 +126,39 @@
 
     }
 
+
+    /**
+     * Checking the compatibilty has to do with generating RPC/encoded stubs.
+     * If the XMLBeans bindings are used encoded binding cannot be done.
+     */
+    private void checkCompatibility(){
+        Map bindingMap = this.configuration.getWom().getBindings();
+        Collection col = bindingMap.values();
+
+        for (Iterator iterator = col.iterator(); iterator.hasNext();) {
+            WSDLBinding b = (WSDLBinding)iterator.next();
+            HashMap bindingOps = b.getBindingOperations();
+            Collection bindingOpsCollection = bindingOps.values();
+            for (Iterator iterator1 = bindingOpsCollection.iterator(); iterator1.hasNext();) {
+                foo((WSDLBindingOperation)iterator1.next());
+            }
+
+        }
+    }
+    protected void foo(WSDLBindingOperation bindingOp) {
+        Iterator extIterator = bindingOp.getInput().getExtensibilityElements()
+                .iterator();
+        while (extIterator.hasNext()) {
+            WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
+            if (element.getType().equals(ExtensionConstants.SOAP_BODY)) {
+                if (WSDLConstants.WSDL_USE_ENCODED.equals(
+                        ((SOAPBody) element).getUse())) {
+                    throw new RuntimeException(
+                            "The use 'encoded' is not supported!");
+                }
+            }
+        }
+    }
     private XmlObject[] convertToXMLObjectArray(Vector vec){
         XmlObject[] xmlObjects = new XmlObject[vec.size()];
         for (int i = 0; i < vec.size(); i++) {

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/Schema.java Tue Aug 23 07:18:38 2005
@@ -37,7 +37,7 @@
     public void setElelment(Element elelment);
     /**
      *
-     * @return
+     *
      */
     public Stack getImportedSchemaStack();
     /**

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLDescriptionImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLDescriptionImpl.java?rev=239412&r1=239411&r2=239412&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLDescriptionImpl.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/wsdl/impl/WSDLDescriptionImpl.java Tue Aug 23 07:18:38 2005
@@ -481,8 +481,9 @@
         if (bindingIterator.hasNext()) {
             return (WSDLBinding) bindingIterator.next();
         }
-        throw new WSDLProcessingException(
-                "No Binding Components are available");
+        return null;
+       // throw new WSDLProcessingException(
+       //       "No Binding Components are available");
     }
 
     public WSDLExtensibilityAttribute createWSDLExtensibilityAttribute() {