You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2006/01/09 13:05:46 UTC

svn commit: r367284 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/schema/template/ codegen/src/org/apache/axis2/schema/writer/ codegen/src/org/apache/axis2/wsdl/codegen/ codegen/src/org/apache/axis2/wsdl/codegen/emitter/ code...

Author: ajith
Date: Mon Jan  9 04:04:47 2006
New Revision: 367284

URL: http://svn.apache.org/viewcvs?rev=367284&view=rev
Log:
1. Updated the codegenerator to support multiple services/ports/bindings and porttypes
 I. Added two new parameters to the codegen/CodeGenConfiguration.java
 II. Updated the MultiLanguageClientEmitter.java to select the service/port first and then select the binding and porttype from that. This allows the codegenerator to cater for multiple porttypes. By default if the service/port is not specified, then the first one is picked.
 III .Moved the codegenconfig loading code to a new class and updated it to handle long parameters (long command line parameters)

2. Fixed a few bugs in the SchemaCompiler and Codegenerator
3. Removed the AxisBindingBuilder from the extensions list

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.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/i18n/resource.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/OptionValidator.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/WSDL2JavaTest.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/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Mon Jan  9 04:04:47 2006
@@ -30,10 +30,11 @@
 
     <!-- this is the common template -->
     <xsl:template match="bean">
-        <!-- write the class header. this should be done only when unwrapped -->
+
         <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+    <!-- write the class header. this should be done only when unwrapped -->
 
-        <xsl:if test="not(@skip-write)">
+        <xsl:if test="not(not(@unwrapped) or (@skip-write))">
             /**
             * <xsl:value-of select="$name"/>.java
             *

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Mon Jan  9 04:04:47 2006
@@ -70,6 +70,7 @@
     private Document globalWrappedDocument;
 
     private Map modelMap = new HashMap();
+    private static final String DEFAULT_PACKAGE = "adb";
 
     /**
      * Default constructor
@@ -108,12 +109,12 @@
                 Element rootElement = XSLTUtils.getElement(globalWrappedDocument, "beans");
                 globalWrappedDocument.appendChild(rootElement);
                 XSLTUtils.addAttribute(globalWrappedDocument, "name", WRAPPED_DATABINDING_CLASS_NAME, rootElement);
-                String tempPackageName = null;
+                String tempPackageName;
 
                 if (packageName !=null && packageName.endsWith(".")) {
                     tempPackageName = this.packageName.substring(0, this.packageName.lastIndexOf("."));
                 }else{
-                    tempPackageName = "adb"; //todo - fix this
+                    tempPackageName = DEFAULT_PACKAGE;
                 }
 
                 XSLTUtils.addAttribute(globalWrappedDocument, "package", tempPackageName, rootElement);
@@ -176,8 +177,13 @@
     public void writeBatch() throws SchemaCompilationException {
         try {
             if (wrapClasses) {
-
-                File out = createOutFile(packageName, WRAPPED_DATABINDING_CLASS_NAME);
+                String tempPackage ;
+                if (packageName==null){
+                   tempPackage = DEFAULT_PACKAGE;
+                }else{
+                    tempPackage = packageName;
+                }
+                File out = createOutFile(tempPackage, WRAPPED_DATABINDING_CLASS_NAME);
                 //parse with the template and create the files
                 parse(globalWrappedDocument, out);
             }
@@ -255,7 +261,7 @@
             globalWrappedDocument.getDocumentElement().appendChild(
                     getBeanElement(globalWrappedDocument, className, originalName, packageName, qName, isElement, metainf, propertyNames, typeMap)
             );
-            packagePrefix =  (this.packageName == null ? "" : this.packageName) + WRAPPED_DATABINDING_CLASS_NAME;
+            packagePrefix =  (this.packageName == null ? DEFAULT_PACKAGE+"." : this.packageName) + WRAPPED_DATABINDING_CLASS_NAME;
 
         } else {
             //create the model
@@ -412,7 +418,7 @@
     /**
      * Given the xml name, make a unique class name taking into account that some
      * file systems are case sensitive and some are not.
-     *
+     * -Consider the Jax-WS spec for this
      * @param listOfNames
      * @param xmlName
      * @return Returns String.

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Mon Jan  9 04:04:47 2006
@@ -33,6 +33,43 @@
 public class CodeGenConfiguration implements CommandLineOptionConstants {
 
     private WSDLDescription wom;
+
+    public void setWom(WSDLDescription wom) {
+        this.wom = wom;
+    }
+
+    public void setOutputLanguage(String outputLanguage) {
+        this.outputLanguage = outputLanguage;
+    }
+
+    public void setAdvancedCodeGenEnabled(boolean advancedCodeGenEnabled) {
+        this.advancedCodeGenEnabled = advancedCodeGenEnabled;
+    }
+
+    public void setAsyncOn(boolean asyncOn) {
+        this.asyncOn = asyncOn;
+    }
+
+    public void setSyncOn(boolean syncOn) {
+        this.syncOn = syncOn;
+    }
+
+    public void setServerSide(boolean serverSide) {
+        this.serverSide = serverSide;
+    }
+
+    public void setGenerateDeployementDescriptor(boolean generateDeployementDescriptor) {
+        this.generateDeployementDescriptor = generateDeployementDescriptor;
+    }
+
+    public void setWriteTestCase(boolean writeTestCase) {
+        this.writeTestCase = writeTestCase;
+    }
+
+    public void setOutputLocation(File outputLocation) {
+        this.outputLocation = outputLocation;
+    }
+
     private File outputLocation;
 
     //get the defaults for these from the property file
@@ -56,6 +93,27 @@
 
     private boolean generateAll = false;
 
+    //user selected portname
+    private String portName;
+    //user selected servicename
+    private String serviceName;
+
+
+    public String getPortName() {
+        return portName;
+    }
+
+    public void setPortName(String portName) {
+        this.portName = portName;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
 
     /**
      * A hashmap to hang the property objects
@@ -203,86 +261,7 @@
      */
     public CodeGenConfiguration(WSDLDescription wom, Map optionMap) {
         this.wom = wom;
-
-        String outputLocation = "."; //default output directory is the current working directory
-        CommandLineOption clo =
-                ((CommandLineOption) optionMap.get(OUTPUT_LOCATION_OPTION));
-        if (clo != null) {
-            outputLocation = clo.getOptionValue();
-        }
-        this.outputLocation = new File(outputLocation);
-
-        //check and create the directories
-        if (this.outputLocation.exists()) {
-            if (this.outputLocation.isFile()) {
-                throw new RuntimeException(CodegenMessages.getMessage("options.notADirectoryException"));
-            }
-        } else {
-            this.outputLocation.mkdirs();
-        }
-
-        serverSide = (optionMap.get(SERVER_SIDE_CODE_OPTION) != null);
-        generateDeployementDescriptor = (optionMap.get(
-                GENERATE_SERVICE_DESCRIPTION_OPTION) !=
-                null);
-        writeTestCase = (optionMap.get(GENERATE_TEST_CASE_OPTION) != null);
-
-        boolean asyncFlagPresent = (optionMap.get(CODEGEN_ASYNC_ONLY_OPTION) !=
-                null);
-        boolean syncFlagPresent = (optionMap.get(CODEGEN_SYNC_ONLY_OPTION) !=
-                null);
-        if (asyncFlagPresent) {
-            this.asyncOn = true;
-            this.syncOn = false;
-        }
-        if (syncFlagPresent) {
-            this.asyncOn = false;
-            this.syncOn = true;
-        }
-
-        CommandLineOption packageOption = (CommandLineOption) optionMap.get(
-                PACKAGE_OPTION);
-        if (packageOption != null) {
-            this.packageName = packageOption.getOptionValue();
-        }
-
-        CommandLineOption langOption = (CommandLineOption) optionMap.get(
-                STUB_LANGUAGE_OPTION);
-        //The language here
-        if (langOption != null) {
-            outputLanguage = langOption.getOptionValue();
-        }
-
-        CommandLineOption dataBindingOption = (CommandLineOption) optionMap.get(
-                DATA_BINDING_TYPE_OPTION);
-        if (dataBindingOption != null) {
-            setDatabindingType(dataBindingOption.getOptionValue());
-        }
-
-        CommandLineOption unwrapClassesOption = (CommandLineOption) optionMap.get(
-                UNPACK_CLASSES_OPTION);
-        if (unwrapClassesOption != null) {
-            packClasses = false;
-        }
-
-        CommandLineOption generateAllOption = (CommandLineOption) optionMap.get(
-                GENERATE_ALL_OPTION);
-        if (generateAllOption != null) {
-            generateAll = true;
-        }
-
-        //loop through the map and find parameters having the extra prefix.
-        //put them in the property map
-        Iterator keyIterator = optionMap.keySet().iterator();
-        while (keyIterator.hasNext()) {
-            Object key = keyIterator.next();
-            CommandLineOption option = (CommandLineOption) optionMap.get(key);
-            if (key.toString().startsWith(EXTRA_OPTIONTYPE_PREFIX)) {
-                //add this to the property map
-                configurationProperties.put(key.toString().replaceFirst(EXTRA_OPTIONTYPE_PREFIX, ""), option.getOptionValue());
-            }
-        }
-
+        CodegenConfigLoader.loadConfig(this,optionMap);
     }
 
 

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java?rev=367284&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java Mon Jan  9 04:04:47 2006
@@ -0,0 +1,131 @@
+package org.apache.axis2.wsdl.codegen;
+
+import org.apache.axis2.wsdl.util.CommandLineOptionConstants;
+import org.apache.axis2.wsdl.util.CommandLineOption;
+import org.apache.axis2.wsdl.i18n.CodegenMessages;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.io.File;
+/*
+ * 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.
+ */
+
+class CodegenConfigLoader implements CommandLineOptionConstants {
+
+    public static void loadConfig(CodeGenConfiguration config, Map optionMap){
+        String outputLocation = "."; //default output directory is the current working directory
+        CommandLineOption outputLocationOption = loadOption(OUTPUT_LOCATION_OPTION,OUTPUT_LOCATION_OPTION_LONG,optionMap);
+
+        if (outputLocationOption != null) {
+            outputLocation = outputLocationOption.getOptionValue();
+        }
+        File outputLocationFile = new File(outputLocation);
+        config.setOutputLocation(outputLocationFile);
+
+        //check and create the directories
+        if (outputLocationFile.exists()) {
+            if (outputLocationFile.isFile()) {
+                throw new RuntimeException(CodegenMessages.getMessage("options.notADirectoryException"));
+            }
+        } else {
+            outputLocationFile.mkdirs();
+        }
+
+        config.setServerSide(loadOption(SERVER_SIDE_CODE_OPTION,SERVER_SIDE_CODE_OPTION_LONG,optionMap) != null);
+        config.setGenerateDeployementDescriptor(loadOption(GENERATE_SERVICE_DESCRIPTION_OPTION,
+                GENERATE_SERVICE_DESCRIPTION_OPTION_LONG,optionMap) !=
+                null);
+        config.setWriteTestCase(loadOption(GENERATE_TEST_CASE_OPTION,GENERATE_TEST_CASE_OPTION,optionMap) != null);
+
+        boolean asyncFlagPresent =
+                (loadOption(CODEGEN_ASYNC_ONLY_OPTION,CODEGEN_ASYNC_ONLY_OPTION_LONG,optionMap) !=  null);
+        boolean syncFlagPresent =
+                (loadOption(CODEGEN_SYNC_ONLY_OPTION,CODEGEN_SYNC_ONLY_OPTION_LONG,optionMap) !=   null);
+        if (asyncFlagPresent) {
+            config.setAsyncOn(true);
+            config.setSyncOn(false);
+        }
+        if (syncFlagPresent) {
+            config.setAsyncOn(false);
+            config.setSyncOn(true);
+        }
+
+        CommandLineOption packageOption = loadOption(PACKAGE_OPTION,PACKAGE_OPTION_LONG,optionMap);
+        if (packageOption != null) {
+            config.setPackageName(packageOption.getOptionValue());
+        }
+
+        CommandLineOption langOption = loadOption(STUB_LANGUAGE_OPTION,STUB_LANGUAGE_OPTION_LONG,optionMap);
+        //The language here
+        if (langOption != null) {
+            config.setOutputLanguage(langOption.getOptionValue());
+        }
+
+        CommandLineOption dataBindingOption = loadOption(DATA_BINDING_TYPE_OPTION,DATA_BINDING_TYPE_OPTION_LONG,optionMap);
+        if (dataBindingOption != null) {
+            config.setDatabindingType(dataBindingOption.getOptionValue());
+        }
+
+        CommandLineOption unwrapClassesOption = loadOption(UNPACK_CLASSES_OPTION,UNPACK_CLASSES_OPTION_LONG,optionMap);
+        if (unwrapClassesOption != null) {
+            config.setPackClasses(false);
+        }
+
+        CommandLineOption portNameOption = loadOption(PORT_NAME_OPTION,PORT_NAME_OPTION_LONG,optionMap);
+        config.setPortName(portNameOption!=null?portNameOption.getOptionValue():null);
+
+        CommandLineOption serviceNameOption = loadOption(SERVICE_NAME_OPTION,SERVICE_NAME_OPTION_LONG,optionMap);
+        config.setServiceName(serviceNameOption!=null?serviceNameOption.getOptionValue():null);
+
+
+        CommandLineOption generateAllOption = loadOption(GENERATE_ALL_OPTION,GENERATE_ALL_OPTION_LONG,optionMap);
+        if (generateAllOption != null) {
+            config.setGenerateAll(true);
+        }
+
+        //loop through the map and find parameters having the extra prefix.
+        //put them in the property map
+        Iterator keyIterator = optionMap.keySet().iterator();
+        while (keyIterator.hasNext()) {
+            Object key = keyIterator.next();
+            CommandLineOption option = (CommandLineOption) optionMap.get(key);
+            if (key.toString().startsWith(EXTRA_OPTIONTYPE_PREFIX)) {
+                //add this to the property map
+                config.getProperties().put(key.toString().replaceFirst(EXTRA_OPTIONTYPE_PREFIX, ""), option.getOptionValue());
+            }
+        }
+
+
+
+    }
+
+    private static CommandLineOption loadOption(String shortOption, String longOption,Map options) {
+        //short option gets precedence
+        CommandLineOption option = null;
+        if (longOption!=null){
+           option =(CommandLineOption)options.get(longOption);
+           if (option!=null) {
+               return option;
+           }
+        }
+        if (shortOption!= null){
+            option = (CommandLineOption)options.get(shortOption);
+        }
+
+        return option;
+    }
+
+}

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=367284&r1=367283&r2=367284&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 Mon Jan  9 04:04:47 2006
@@ -5,7 +5,7 @@
 # these are loaded in their lexical order
 # Note the last extension - It includes a check to figure out whether proper databinding has taken place
 # This extension should appear AFTER all the databinding extensions inorder to function properly
-codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
+codegen.extension=org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
 #codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension
 # The third party schemas to be loaded. e.g. The Xmime extension
 # Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.

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=367284&r1=367283&r2=367284&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 Mon Jan  9 04:04:47 2006
@@ -87,6 +87,15 @@
     protected TypeMapper mapper;
     protected URIResolver resolver;
 
+    /**
+     * This information holder keeps the necessary information of
+     * what to codegen. The service, port, binding (and the porttype)
+     * if the service and binding tags are missing then only the
+     * portype wil be there
+     * This will get populated before executing any code generation
+     */
+    protected InformationHolder infoHolder = null;
+
 
     /**
      * Sets the mapper.
@@ -100,31 +109,37 @@
 
     /**
      * Sets the code generator configuration.
-     *
+     * This needs to be called before asking to codegen
      * @param configuration
      */
     public void setCodeGenConfiguration(CodeGenConfiguration configuration) {
         this.configuration = configuration;
         resolver = new XSLTIncludeResolver(this.configuration.getProperties());
+
+        //select necessary information from the WOM
+        populateInformationHolder();
+
     }
 
+
+
+
     /**
      * @see org.apache.axis2.wsdl.codegen.emitter.Emitter#emitSkeleton()
      */
     public void emitSkeleton() throws CodeGenerationException {
         try {
             //get the interface
-            WSDLDescription wom = this.configuration.getWom();
             int codegenStyle = this.configuration.getCodeGenerationStyle();
             if (codegenStyle == XSLTConstants.CodegenStyle.INTERFACE) {
-                emitSkeletonInterface(wom);
+                emitSkeletonInterface();
             } else if (codegenStyle == XSLTConstants.CodegenStyle.BINDING) {
-                emitSkeletonBinding(wom);
+                emitSkeletonBinding();
             } else if (codegenStyle == XSLTConstants.CodegenStyle.AUTOMATIC) {
-                emitSkeletonAutomatic(wom);
+                emitSkeletonAutomatic();
             } else {
                 throw new Exception(
-                         CodegenMessages.getMessage("emitter.unknownStyle", codegenStyle+"")) ;
+                        CodegenMessages.getMessage("emitter.unknownStyle", codegenStyle+"")) ;
             }
 
             // Call the emit stub method to generate the client side too
@@ -144,14 +159,13 @@
     public void emitStub() throws CodeGenerationException {
         try {
             //get the interface
-            WSDLDescription wom = this.configuration.getWom();
             int codegenStyle = this.configuration.getCodeGenerationStyle();
             if (codegenStyle == XSLTConstants.CodegenStyle.INTERFACE) {
-                emitStubInterface(wom);
+                emitStubInterface();
             } else if (codegenStyle == XSLTConstants.CodegenStyle.BINDING) {
-                emitStubBinding(wom);
+                emitStubBinding();
             } else if (codegenStyle == XSLTConstants.CodegenStyle.AUTOMATIC) {
-                emitStubAutomatic(wom);
+                emitStubAutomatic();
             } else {
                 throw new Exception( CodegenMessages.getMessage("emitter.unknownStyle", codegenStyle+""));
             }
@@ -166,20 +180,13 @@
      *
      * @param wom
      */
-    private void emitSkeletonInterface(WSDLDescription wom) throws Exception {
+    private void emitSkeletonInterface() throws Exception {
 
-        Map interfaces = wom.getWsdlInterfaces();
+        //write skeleton
+        writeSkeleton();
+        //write interface implementations
+        writeServiceXml();
 
-        //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, null);
-            //write interface implementations
-            writeServiceXml(axisInteface,wom);
-        }
 
 
         log.info(CodegenMessages.getMessage("emitter.logEntryInterface1"));
@@ -191,37 +198,35 @@
      *
      * @param wom
      */
-    private void emitSkeletonBinding(WSDLDescription wom) throws Exception {
-        Map bindings = wom.getBindings();
-        if (bindings == null || bindings.isEmpty()) {
+    private void emitSkeletonBinding() throws Exception {
+
+        WSDLBinding axisBinding;
+
+        axisBinding = infoHolder.getBinding();
+        WSDLInterface wsInterface = infoHolder.getPorttype();
+
+        if (axisBinding == null) {
             //asking for a code generation with a binding when a binding is
             //not present should be the cause of an Exception !
             throw new Exception(CodegenMessages.getMessage("emitter.cannotFindBinding"));
 
-        } else {
-            WSDLBinding axisBinding;
-            Collection bindingCollection = bindings.values();
-            for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
-                axisBinding = (WSDLBinding) iterator.next();
-
-                //see the comment at updateMapperClassnames for details and reasons for
-                //calling this method
-                if (mapper.isObjectMappingPresent()){
-                    updateMapperForMessageReceiver(axisBinding.getBoundInterface());
-                }
-                //write skeleton
-                writeSkeleton(axisBinding.getBoundInterface(), axisBinding);
-                //write service xml
-                writeServiceXml(axisBinding,wom);
-                //write a MessageReceiver for this particular service.
-                writeMessageReceiver(axisBinding);
-                //write the ant build if not asked for all
-                if (!configuration.isGenerateAll()) {
-                    writeAntBuild(axisBinding.getBoundInterface(), axisBinding, wom);
-                }
-
-            }
         }
+        //see the comment at updateMapperClassnames for details and reasons for
+        //calling this method
+        if (mapper.isObjectMappingPresent()){
+            updateMapperForMessageReceiver(wsInterface);
+        }
+        //write skeleton
+        writeSkeleton();
+        //write service xml
+        writeServiceXml();
+        //write a MessageReceiver for this particular service.
+        writeMessageReceiver();
+        //write the ant build if not asked for all
+        if (!configuration.isGenerateAll()) {
+            writeAntBuild();
+        }
+
     }
 
     /**
@@ -229,14 +234,14 @@
      *
      * @param wom
      */
-    private void emitSkeletonAutomatic(WSDLDescription wom) throws Exception {
-        Map bindings = wom.getBindings();
-        if (bindings == null || bindings.isEmpty()) {
+    private void emitSkeletonAutomatic() throws Exception {
+
+        if (infoHolder.getBinding() == null ) {
             //No binding is present.use the interface mode
-            emitSkeletonInterface(wom);
+            emitSkeletonInterface();
         } else {
             //use the binding mode
-            emitSkeletonBinding(wom);
+            emitSkeletonBinding();
         }
 
     }
@@ -247,25 +252,25 @@
      * @param wom
      * @throws Exception
      */
-    private void emitStubInterface(WSDLDescription wom) throws Exception {
-        Map interfaces = wom.getWsdlInterfaces();
-        //loop through the wsdlInterfaces to generate the interface code
-        Collection interfaceCollection = interfaces.values();
-        for (Iterator iterator = interfaceCollection.iterator(); iterator.hasNext();) {
-            //Write the interfaces
-            WSDLInterface axisInterface = (WSDLInterface) iterator.next();
-            //note that this case we do not care about the wrapping flag
-            writeInterface(axisInterface, null);
-            //write the call back handlers
-            writeCallBackHandlers(axisInterface, null);
+    private void emitStubInterface() throws Exception {
+        WSDLInterface axisInterface = infoHolder.getPorttype();
+        if (mapper.isObjectMappingPresent()){
+            updateMapperForInterface(axisInterface);
         }
+        //Write the interfaces
+        //note that this case we do not care about the wrapping flag
+        writeInterface(true);
+
+        //write the call back handlers
+        writeCallBackHandlers();
+
 
         //log the message stating that the binding dependent parts are not generated
-         log.info(CodegenMessages.getMessage("emitter.logEntryInterface1"));
-         log.info(CodegenMessages.getMessage("emitter.logEntryInterface3"));
-         log.info(CodegenMessages.getMessage("emitter.logEntryInterface4"));
-         log.info(CodegenMessages.getMessage("emitter.logEntryInterface5"));
-         log.info(CodegenMessages.getMessage("emitter.logEntryInterface6"));
+        log.info(CodegenMessages.getMessage("emitter.logEntryInterface1"));
+        log.info(CodegenMessages.getMessage("emitter.logEntryInterface3"));
+        log.info(CodegenMessages.getMessage("emitter.logEntryInterface4"));
+        log.info(CodegenMessages.getMessage("emitter.logEntryInterface5"));
+        log.info(CodegenMessages.getMessage("emitter.logEntryInterface6"));
 
     }
 
@@ -275,49 +280,35 @@
      * @param wom
      * @throws Exception
      */
-    private void emitStubBinding(WSDLDescription wom) throws Exception {
-        Map bindings = wom.getBindings();
-        if (bindings == null || bindings.isEmpty()) {
-            //asking for a code generation with a binding when a binding is
-            //not present should be the cause of an Exception !
-            throw new Exception(CodegenMessages.getMessage("emitter.cannotFindBinding"));
-        } 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);
-
-                //see the comment at updateMapperClassnames for details and reasons for
-                //calling this method
-                if (mapper.isObjectMappingPresent()){
-                    updateMapperForStub(axisBinding.getBoundInterface());
-                }
+    private void emitStubBinding() throws Exception {
 
-                //write the inteface
-                //feed the binding information also
-                //note that we do not create this interface if the user switched on the wrap classes mode
-                if (!configuration.isPackClasses()) {
-                    writeInterface(axisBinding.getBoundInterface(), axisBinding);
-                }
-                //write the call back handlers
-                writeCallBackHandlers(axisBinding.getBoundInterface(), axisBinding);
-                //write interface implementations
-                writeInterfaceImplementation(axisBinding, axisService);
-                //write the test classes
-                writeTestClasses(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 an ant build file
-                writeAntBuild(axisBinding.getBoundInterface(), axisBinding, wom);
-            }
+        WSDLInterface axisInterface = infoHolder.getPorttype();
+
+        //see the comment at updateMapperClassnames for details and reasons for
+        //calling this method
+        if (mapper.isObjectMappingPresent()){
+            updateMapperForStub(axisInterface);
         }
+
+        //write the inteface
+        //feed the binding information also
+        //note that we do not create this interface if the user switched on the wrap classes mode
+        if (!configuration.isPackClasses()) {
+            writeInterface(false);
+        }
+        //write the call back handlers
+        writeCallBackHandlers();
+        //write interface implementations
+        writeInterfaceImplementation();
+        //write the test classes
+        writeTestClasses();
+
+        //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 an ant build file
+        writeAntBuild();
     }
 
     /**
@@ -327,7 +318,7 @@
      * to suit the expected package to be written
      * in this case we modify the package name to have make the class a inner class of the stub
      */
-    private void updateMapperClassnames(WSDLInterface boundInterface,String fullyQulifiedIncludingClassNamePrefix) {
+    private void updateMapperClassnames(String fullyQulifiedIncludingClassNamePrefix) {
         Map classNameMap = mapper.getAllMappedNames();
         Iterator keys = classNameMap.keySet().iterator();
         while (keys.hasNext()) {
@@ -339,16 +330,22 @@
 
     private void updateMapperForStub(WSDLInterface boundInterface){
         String packageName = configuration.getPackageName();
-        String localPart = makeJavaClassName(boundInterface.getName().getLocalPart());
+        String localPart = getCoreClassName(boundInterface);
         String stubName = localPart + STUB_SUFFIX;
-        updateMapperClassnames(boundInterface,packageName + "." + stubName + ".");
+        updateMapperClassnames(packageName + "." + stubName + ".");
+    }
+
+    private void updateMapperForInterface(WSDLInterface boundInterface){
+        String packageName = configuration.getPackageName();
+        String interfaceName = getCoreClassName(boundInterface);
+        updateMapperClassnames(packageName + "." + interfaceName + ".");
     }
 
     private void updateMapperForMessageReceiver(WSDLInterface boundInterface){
         String packageName = configuration.getPackageName();
-        String localPart = makeJavaClassName(boundInterface.getName().getLocalPart());
-        String stubName = localPart + MESSAGE_RECEIVER_SUFFIX;
-        updateMapperClassnames(boundInterface,packageName + "." + stubName + ".");
+        String localPart = getCoreClassName(boundInterface);
+        String messageReceiver = localPart + MESSAGE_RECEIVER_SUFFIX;
+        updateMapperClassnames(packageName + "." + messageReceiver + ".");
     }
     /**
      * emit the stubcode with the automatic mode. Look for the binding and if present
@@ -356,47 +353,26 @@
      *
      * @param wom
      */
-    private void emitStubAutomatic(WSDLDescription wom) throws Exception {
-        Map bindings = wom.getBindings();
-        if (bindings == null || bindings.isEmpty()) {
+    private void emitStubAutomatic() throws Exception {
+        if (infoHolder.getBinding() == null) {
             //No binding is not present.use the interface mode
-            emitStubInterface(wom);
+            emitStubInterface();
         } else {
             //use the binding mode
-            emitStubBinding(wom);
+            emitStubBinding();
         }
     }
 
-    /**
-     * Check the service for compatibility. Am incompatible service consists of
-     * multiple services ATM
-     *
-     * @param wom
-     * @param axisService
-     * @return the WSDLService object
-     */
-    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(
-                       CodegenMessages.getMessage("emitter.SingleServiceMessage"));
-            }
-        }
-        return axisService;
-    }
+
 
 
     /**
      * Writes the callback handlers.
      */
-    protected void writeCallBackHandlers(WSDLInterface wsdlInterface, WSDLBinding axisBinding) throws Exception {
+    protected void writeCallBackHandlers() throws Exception {
 
         if (configuration.isAsyncOn()) {
-            Document interfaceModel = createDOMDocumentForCallbackHandler(
-                    wsdlInterface, axisBinding);
+            Document interfaceModel = createDOMDocumentForCallbackHandler();
             CallbackHandlerWriter callbackWriter =
                     new CallbackHandlerWriter(
                             getOutputDirectory(this.configuration.getOutputLocation(), "src"),
@@ -410,10 +386,10 @@
     /**
      *
      */
-    protected void writeTestClasses(WSDLBinding binding) throws Exception {
+    protected void writeTestClasses() throws Exception {
 
         if (configuration.isWriteTestCase()) {
-            Document classModel = createDOMDocumentForTestCase(binding);
+            Document classModel = createDOMDocumentForTestCase();
             TestClassWriter callbackWriter =
                     new TestClassWriter(
                             getOutputDirectory(this.configuration.getOutputLocation(), "test"),
@@ -430,13 +406,14 @@
      * @param axisBinding
      * @throws Exception
      */
-    protected void writeInterface(WSDLInterface axisInterface, WSDLBinding axisBinding) throws Exception {
+    protected void writeInterface(boolean writeDatabinders) throws Exception {
 
-        Document interfaceModel = createDOMDocumentForInterface(axisInterface, axisBinding);
+        Document interfaceModel = createDOMDocumentForInterface(writeDatabinders);
         InterfaceWriter interfaceWriter =
                 new InterfaceWriter(
                         getOutputDirectory(this.configuration.getOutputLocation(), "src"),
                         this.configuration.getOutputLanguage());
+
         writeClass(interfaceModel, interfaceWriter);
 
     }
@@ -449,10 +426,10 @@
      * @param axisBinding
      * @throws Exception
      */
-    protected void writeSkeleton(WSDLInterface axisInteface, WSDLBinding axisBinding) throws Exception {
+    protected void writeSkeleton() throws Exception {
 
         //Note -  One can generate the skeleton using the interface XML
-        Document skeletonModel = createDOMDocumentForSkeleton(axisInteface, axisBinding);
+        Document skeletonModel = createDOMDocumentForSkeleton();
         ClassWriter skeletonWriter = new SkeletonWriter(
                 getOutputDirectory(this.configuration.getOutputLocation(), "src"),
                 this.configuration.getOutputLanguage());
@@ -469,10 +446,9 @@
      * @param axisBinding
      * @throws Exception
      */
-    protected void writeAntBuild(WSDLInterface axisInterface, WSDLBinding axisBinding, WSDLDescription desc) throws Exception {
+    protected void writeAntBuild() throws Exception {
         //Write the service xml in a folder with the
-        Document skeletonModel = createDOMDocumentForAntBuild(
-                axisInterface, axisBinding, desc);
+        Document skeletonModel = createDOMDocumentForAntBuild();
 
 
         AntBuildWriter antBuildWriter = new AntBuildWriter(
@@ -489,36 +465,18 @@
      * @param desc
      * @throws Exception
      */
-    protected void writeServiceXml(WSDLBinding axisBinding,WSDLDescription desc) throws Exception {
+    protected void writeServiceXml() throws Exception {
         if (this.configuration.isGenerateDeployementDescriptor()) {
             //Write the service xml in a folder with the
-            Document skeletonModel = createDOMDocumentForServiceXML(
-                    axisBinding.getBoundInterface(), axisBinding,desc);
+            Document serviceXMLModel = createDOMDocumentForServiceXML();
             ClassWriter serviceXmlWriter = new ServiceXMLWriter(
                     getOutputDirectory(this.configuration.getOutputLocation(), "resources"),
                     this.configuration.getOutputLanguage());
-            writeClass(skeletonModel, serviceXmlWriter);
+            writeClass(serviceXMLModel, serviceXmlWriter);
         }
     }
 
-    /**
-     * Writes the Service XML.
-     *
-     * @param axisInterface
-     * @param desc
-     * @throws Exception
-     */
-    protected void writeServiceXml(WSDLInterface axisInterface,WSDLDescription desc) throws Exception {
-        if (this.configuration.isGenerateDeployementDescriptor()) {
-            //Write the service xml in a folder with the
-            Document skeletonModel = createDOMDocumentForServiceXML(
-                    axisInterface, null,desc);
-            ClassWriter serviceXmlWriter = new ServiceXMLWriter(
-                    getOutputDirectory(this.configuration.getOutputLocation(), "resources"),
-                    this.configuration.getOutputLanguage());
-            writeClass(skeletonModel, serviceXmlWriter);
-        }
-    }
+
 
 
     /**
@@ -527,11 +485,9 @@
      * @param axisBinding
      * @throws Exception
      */
-    protected void writeInterfaceImplementation(WSDLBinding axisBinding,
-                                                WSDLService service) throws Exception {
+    protected void writeInterfaceImplementation() throws Exception {
         //first check for the policies in this service and write them
-        Document interfaceImplModel = createDOMDocumentForInterfaceImplementation(
-                axisBinding, service);
+        Document interfaceImplModel = createDOMDocumentForInterfaceImplementation();
         InterfaceImplementationWriter writer =
                 new InterfaceImplementationWriter(
                         getOutputDirectory(this.configuration.getOutputLocation(), "src"),
@@ -539,10 +495,9 @@
         writeClass(interfaceImplModel, writer);
     }
 
-    protected void writeMessageReceiver(WSDLBinding binding) throws Exception {
+    protected void writeMessageReceiver() throws Exception {
         if (configuration.isWriteMessageReceiver()) {
-            Document classModel = createDocumentForMessageReceiver(
-                    binding);
+            Document classModel = createDocumentForMessageReceiver();
             MessageReceiverWriter writer =
                     new MessageReceiverWriter(
                             getOutputDirectory(this.configuration.getOutputLocation(), "src"),
@@ -563,9 +518,11 @@
     protected void writeClass(Document model, ClassWriter writer) throws IOException,
             Exception {
         writer.loadTemplate();
+        String packageName = model.getDocumentElement().getAttribute("package");
+        String className = model.getDocumentElement().getAttribute("name");
         writer.createOutFile(
-                model.getDocumentElement().getAttribute("package"),
-                model.getDocumentElement().getAttribute("name"));
+                packageName,
+                className);
         //use the global resolver
         writer.parse(model,resolver);
     }
@@ -586,9 +543,13 @@
      * @param boundInterface
      * @param axisBinding
      */
-    protected Document createDOMDocumentForCallbackHandler(
-            WSDLInterface boundInterface, WSDLBinding axisBinding) {
+    protected Document createDOMDocumentForCallbackHandler() {
+
         Document doc = getEmptyDocument();
+
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+        WSDLBinding  axisBinding = infoHolder.getBinding();
+
         Element rootElement = doc.createElement("callback");
         addAttribute(doc,
                 "package",
@@ -596,7 +557,7 @@
                 rootElement);
         addAttribute(doc,
                 "name",
-                makeJavaClassName(boundInterface.getName().getLocalPart()) +
+                getCoreClassName(boundInterface) +
                         CALL_BACK_HANDLER_SUFFIX,
                 rootElement);
         addAttribute(doc,
@@ -757,18 +718,6 @@
         return param;
     }
 
-    /**
-     * @see  #createDOMDocumentForServiceXML(org.apache.wsdl.WSDLInterface, org.apache.wsdl.WSDLBinding, org.apache.wsdl.WSDLDescription)
-     * @param boundInterface
-     * @param axisBinding
-     * @return Returns Document.
-     */
-    protected Document createDOMDocumentForServiceXML(WSDLInterface boundInterface ,
-                                                      WSDLBinding axisBinding) {
-        return createDOMDocumentForServiceXML(boundInterface ,
-                axisBinding,null);
-
-    }
 
 
     /**
@@ -778,72 +727,32 @@
      * @param description
      * @return Returns Document.
      */
-    protected Document createDOMDocumentForServiceXML(WSDLInterface boundInterface ,
-                                                      WSDLBinding axisBinding,
-                                                      WSDLDescription description) {
+    protected Document createDOMDocumentForServiceXML() {
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+        WSDLBinding  axisBinding = infoHolder.getBinding();
+        WSDLService service =infoHolder.getService();
 
         Document doc = getEmptyDocument();
-        String porttypeName = makeJavaClassName(boundInterface.getName().getLocalPart());
+        String coreClassName = getCoreClassName(boundInterface);
 
-        Map relevantServicesMap = getServicesMap(description, boundInterface);
 
-        Iterator relevantServicesIterator = relevantServicesMap.keySet().iterator();
-        if (relevantServicesMap.isEmpty()){
-            //No service name. Make a service name here. Our choice for now is the
-            //portype name
+        // WSDLEndpoint endpoint = infoHolder.getPort();
+        if (service!=null){
+            doc.appendChild(getServiceElement(
+                    service.getName().getLocalPart(),coreClassName,doc, boundInterface, axisBinding));
+        }else{
+            //service is missing. However we can derive a service name from the porttype
             doc.appendChild(getServiceElement(
-                    porttypeName,porttypeName, doc, boundInterface, axisBinding));
+                    boundInterface.getName().getLocalPart(),coreClassName,doc, boundInterface, axisBinding));
+        }
+
 
-        }else if (relevantServicesMap.size()==1){
-            //do the usual addition to attach a single interface element
-            QName serviceName = (QName)relevantServicesIterator.next();
-            //get the service object
-            WSDLService service = (WSDLService)relevantServicesMap.get(serviceName);
-            HashMap endpoints = service.getEndpoints();
-            //if this service element contains multiple endpoints, we generate a service group
-            //which has multiple service elements that refer to the same service
-            if (endpoints.size()>1){
-                Iterator endpointsIterator = endpoints.values().iterator();
-                Element rootElement = doc.createElement("interfaces");
-                doc.appendChild(rootElement);
-                while (endpointsIterator.hasNext()) {
-                    WSDLEndpoint ep =  (WSDLEndpoint)endpointsIterator.next();
-                    rootElement.appendChild(getServiceElement(
-                            ep.getName().getLocalPart(),porttypeName,doc, boundInterface, axisBinding));
-                }
-            }else{
-                //it's a single endpoint reference. so just add it
-                doc.appendChild(getServiceElement(
-                        serviceName.getLocalPart(),porttypeName,doc, boundInterface, axisBinding));
-            }
-        }else {
-            //we have multiple service elements! So make it into a service group
-            Element rootElement = doc.createElement("interfaces");
-            doc.appendChild(rootElement);
-            while (relevantServicesIterator.hasNext()) {
-                QName serviceName = (QName)relevantServicesIterator.next();
-                rootElement.appendChild(getServiceElement(
-                        serviceName.getLocalPart(),porttypeName,doc, boundInterface, axisBinding));
 
-            }
-        }
 
         return doc;
     }
 
-    private Map getServicesMap(WSDLDescription description, WSDLInterface boundInterface) {
-        //find service that are attached to this binding
-        Map serviceMap  =  description.getServices();
-        Map relevantServicesMap = new HashMap();
-        Iterator serviceIterator = serviceMap.values().iterator();
-        while (serviceIterator.hasNext()) {
-            WSDLService service = (WSDLService)serviceIterator.next();
-            if (service.getServiceInterface().equals(boundInterface)){
-                relevantServicesMap.put(service.getName(),service);
-            }
-        }
-        return relevantServicesMap;
-    }
+
 
     /**
      * Gets the element.
@@ -887,15 +796,17 @@
     }
 
 
-    protected Document createDocumentForMessageReceiver( WSDLBinding binding) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
+    protected Document createDocumentForMessageReceiver() {
+        WSDLBinding binding = infoHolder.getBinding();
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("interface");
         addAttribute(doc,
                 "package",
                 configuration.getPackageName(),
                 rootElement);
-        String localPart = makeJavaClassName(boundInterface.getName().getLocalPart());
+        String localPart = getCoreClassName(boundInterface);
         addAttribute(doc,
                 "name",
                 localPart + MESSAGE_RECEIVER_SUFFIX,
@@ -944,12 +855,16 @@
      * @param wsdlInterface
      * @param axisBinding
      */
-    protected Document createDOMDocumentForAntBuild(WSDLInterface wsdlInterface, WSDLBinding axisBinding, 
-                                                    WSDLDescription desc) {
+    protected Document createDOMDocumentForAntBuild() {
+
+        WSDLInterface wsdlInterface = infoHolder.getPorttype();
+        WSDLService service =infoHolder.getService();
 
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("ant");
-        String localPart = makeJavaClassName(wsdlInterface.getName().getLocalPart());
+
+        String localPart = getCoreClassName(wsdlInterface);
+
         String packageName = configuration.getPackageName();
         String[] dotSeparatedValues = packageName.split("\\.");
         addAttribute(doc,
@@ -961,18 +876,17 @@
                 "name",
                 localPart,
                 rootElement);
-        
+
         String servicename = localPart;
-        Map relevantServicesMap = getServicesMap(desc, wsdlInterface);
-        if(relevantServicesMap.size()>0){
-            servicename = ((QName)relevantServicesMap.keySet().iterator().next()).getLocalPart();    
-        }
-        
-        addAttribute(doc, 
-                "servicename", 
-                servicename, 
+        if (service!=null){
+            servicename = service.getName().getLocalPart();
+        }
+
+        addAttribute(doc,
+                "servicename",
+                servicename,
                 rootElement);
-        
+
         doc.appendChild(rootElement);
         return doc;
 
@@ -984,11 +898,14 @@
      * @param wsdlInterface
      * @param axisBinding
      */
-    protected Document createDOMDocumentForInterface(WSDLInterface wsdlInterface, WSDLBinding axisBinding) {
+    protected Document createDOMDocumentForInterface(boolean writeDatabinders) {
 
         Document doc = getEmptyDocument();
+        WSDLInterface wsdlInterface = infoHolder.getPorttype();
+        WSDLBinding axisBinding = infoHolder.getBinding();
+
         Element rootElement = doc.createElement("interface");
-        String localPart = makeJavaClassName(wsdlInterface.getName().getLocalPart());
+        String localPart = getCoreClassName(wsdlInterface);
         addAttribute(doc,
                 "package",
                 configuration.getPackageName(),
@@ -1005,6 +922,24 @@
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(wsdlInterface, doc, rootElement, axisBinding);
+        //###########################################################################################
+        //this block of code specifically applies to the integration of databinding code into the
+        //generated classes tightly (probably as inner classes)
+        //###########################################################################################
+        //check for the special models in the mapper and if they are present process them
+        if (writeDatabinders){
+            if (mapper.isObjectMappingPresent()){
+                // add an attribute to the root element showing that the writing has been skipped
+                addAttribute(doc,
+                        "skip-write",
+                        "yes",
+                        rootElement);
+                //process the mapper objects
+                processModelObjects(mapper.getAllMappedObjects(),rootElement,doc);
+            }
+
+        }
+        // #############################################################################################
         doc.appendChild(rootElement);
         return doc;
 
@@ -1018,11 +953,15 @@
      * @param axisBinding
      * @return Returns documentModel for the skeleton.
      */
-    protected Document createDOMDocumentForSkeleton(WSDLInterface boundInterface, WSDLBinding axisBinding) {
+    protected Document createDOMDocumentForSkeleton() {
 
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("interface");
-        String localpart = makeJavaClassName(boundInterface.getName().getLocalPart());
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+        WSDLBinding  axisBinding = infoHolder.getBinding();
+
+        //name the skeleton after the binding's name !
+        String localpart = getCoreClassName(boundInterface);
         addAttribute(doc,
                 "package",
                 configuration.getPackageName(),
@@ -1081,7 +1020,7 @@
                                 WSDLBinding binding) {
 
         Collection col = boundInterface.getOperations().values();
-        String portTypeName = makeJavaClassName(boundInterface.getName().getLocalPart());
+        String portTypeName = getCoreClassName(boundInterface);
 
         Element methodElement;
         WSDLOperation operation;
@@ -1171,9 +1110,11 @@
         }
     }
 
-    protected Document createDOMDocumentForTestCase(WSDLBinding binding) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
-        String localPart = makeJavaClassName(boundInterface.getName().getLocalPart());
+    protected Document createDOMDocumentForTestCase() {
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+        WSDLBinding  binding = infoHolder.getBinding();
+
+        String localPart = getCoreClassName(boundInterface);
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("class");
         addAttribute(doc,
@@ -1307,18 +1248,17 @@
      * @param binding
      * @param service
      */
-    protected Document createDOMDocumentForInterfaceImplementation(
-            WSDLBinding binding, WSDLService service) throws Exception {
-        WSDLInterface boundInterface = binding.getBoundInterface();
+    protected Document createDOMDocumentForInterfaceImplementation() throws Exception {
+
+        WSDLInterface boundInterface = infoHolder.getPorttype();
+        WSDLBinding binding = infoHolder.getBinding();
+
 
         String packageName = configuration.getPackageName();
-        String localPart = makeJavaClassName(boundInterface.getName().getLocalPart());
+        String localPart = getCoreClassName(boundInterface);
         String stubName = localPart + STUB_SUFFIX;
 
-        HashMap endpoints = new HashMap(1);
-        if (service != null) {
-            endpoints = service.getEndpoints();
-        }
+
 
         Document doc = getEmptyDocument();
         Element rootElement = doc.createElement("class");
@@ -1353,7 +1293,7 @@
         //add SOAP version
         addSoapVersion(binding, doc, rootElement);
         //add the end point
-        addEndpoints(doc, rootElement, endpoints);
+        addEndpoint(doc, rootElement);
         //set the sync/async attributes
         fillSyncAttributes(doc, rootElement);
 
@@ -1441,18 +1381,13 @@
      * @param endpointMap
      */
 
-    protected void addEndpoints(Document doc,
-                                Element rootElement,
-                                HashMap endpointMap) throws Exception {
-        // Map endpointPolicyMap = configuration.getPolicyMap();
-        Object[] endpoints = endpointMap.values().toArray();
-        WSDLEndpoint endpoint;
-        Element endpointElement;
-        Text text;
-        for (int i = 0; i < endpoints.length; i++) {
-            endpoint = (WSDLEndpoint) endpoints[i];
+    protected void addEndpoint(Document doc,
+                               Element rootElement
+    ) throws Exception {
+
+        WSDLEndpoint  endpoint =  infoHolder.getPort();
 
-            //attach the policy for this endpoint here
+        //attach the policy for this endpoint here
 //            String policyFileResourceName = null;
 //            Policy policy =  (Policy)endpointPolicyMap.get(endpoint.getName());
 //            if (policy!=null){
@@ -1462,23 +1397,24 @@
 //            }
 
 
-            endpointElement = doc.createElement("endpoint");
-            org.apache.wsdl.extensions.SOAPAddress address = null;
-            Iterator iterator = endpoint.getExtensibilityElements().iterator();
-            while (iterator.hasNext()) {
-                WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
-                if (ExtensionConstants.SOAP_11_ADDRESS.equals(element.getType()) ||
-                        ExtensionConstants.SOAP_12_ADDRESS.equals(element.getType())) {
-                    address = (org.apache.wsdl.extensions.SOAPAddress) element;
-                }
+        Element endpointElement = doc.createElement("endpoint");
+        org.apache.wsdl.extensions.SOAPAddress address = null;
+        Iterator iterator = endpoint.getExtensibilityElements().iterator();
+        while (iterator.hasNext()) {
+            WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
+            if (ExtensionConstants.SOAP_11_ADDRESS.equals(element.getType()) ||
+                    ExtensionConstants.SOAP_12_ADDRESS.equals(element.getType())) {
+                address = (org.apache.wsdl.extensions.SOAPAddress) element;
             }
-            text = doc.createTextNode(address != null ? address.getLocationURI() : "");
+        }
+        Text text = doc.createTextNode(address != null ? address.getLocationURI() : "");
 //            if (policyFileResourceName!=null){
 //                addAttribute(doc,"policyRef",policyFileResourceName,endpointElement);
 //            }
-            endpointElement.appendChild(text);
-            rootElement.appendChild(endpointElement);
-        }
+        endpointElement.appendChild(text);
+        rootElement.appendChild(endpointElement);
+
+
 
     }
 
@@ -1585,6 +1521,159 @@
             outputDir.mkdirs();
         }
         return outputDir;
+    }
+
+    private String getCoreClassName(WSDLInterface wsInterface){
+        if (wsInterface!=null){
+            return makeJavaClassName(wsInterface.getName().getLocalPart());
+        }else{
+            throw new RuntimeException(CodegenMessages.getMessage("emitter.coreclassNameError"));
+        }
+
+    }
+
+    /**
+     * Populate the info holder looking at the WOM
+     *
+     */
+    private void populateInformationHolder(){
+        infoHolder = new InformationHolder();
+
+        WSDLDescription wsdlDescription = configuration.getWom();
+        int codegenStyle = this.configuration.getCodeGenerationStyle();
+
+        //user explicity asked for the interface mode, so we can get
+        //away with the populating the portype only
+        if (codegenStyle==XSLTConstants.CodegenStyle.INTERFACE){
+            populatePorttype(infoHolder,wsdlDescription);
+            return;
+        }
+
+        //start with the service
+        Map services = wsdlDescription.getServices();
+        if (services != null && !services.isEmpty()){
+            WSDLService selectedService;
+            WSDLEndpoint selectedEndpoint;
+
+            if (services.size() > 1){
+                //look for the users setting here
+                if (configuration.getServiceName()!=null){
+                    selectedService = wsdlDescription.getService(
+                            new QName(configuration.getWom().getTargetNameSpace(),
+                                    configuration.getServiceName()));
+                    if (selectedService==null){
+                        throw new RuntimeException(
+                                CodegenMessages.getMessage("emitter.serviceNotFoundError",configuration.getServiceName()));
+                    }
+                }else{
+                    //print warning
+                    System.out.println(CodegenMessages.getMessage("emitter.warningMultipleServices"));
+                    selectedService = (WSDLService)services.values().iterator().next();//note - we are sure of no NPE's here
+                }
+            }else{
+                selectedService = (WSDLService)services.values().iterator().next();//note - we are sure of no NPE's here
+            }
+            infoHolder.setService(selectedService);
+
+            //get the ports from the service
+            Map endpoints = selectedService.getEndpoints();
+
+            if (endpoints!=null && !endpoints.isEmpty()){
+                if (endpoints.size()>1){
+                    //look for the users setting here
+                    if (configuration.getPortName()!=null){
+                        selectedEndpoint = selectedService.getEndpoint(
+                                new QName(configuration.getWom().getTargetNameSpace(),
+                                        configuration.getPortName())
+                        );
+                        if (selectedEndpoint==null){
+                            throw new RuntimeException(CodegenMessages.getMessage("emitter.endpointNotFoundError"));
+                        }
+                    }else{
+                        System.out.println(CodegenMessages.getMessage("emitter.warningMultipleEndpoints"));
+                        selectedEndpoint = (WSDLEndpoint)endpoints.values().iterator().next();
+                    }
+                }else{
+                    selectedEndpoint = (WSDLEndpoint)endpoints.values().iterator().next();
+                }
+
+                infoHolder.setPort(selectedEndpoint);
+                WSDLBinding binding = selectedEndpoint.getBinding();
+                infoHolder.setBinding(binding);
+                infoHolder.setPorttype(binding.getBoundInterface());
+
+            }else{
+                //having no endpoints?? this is surely an exception
+                throw new RuntimeException(CodegenMessages.getMessage("emitter.noEndpointsFoundError"));
+            }
+
+
+        }else{
+            //log warning saying that the service was not found and switching to the interface mode
+            System.out.println(CodegenMessages.getMessage("emitter.switchingMessages"));
+            populatePorttype(infoHolder,wsdlDescription);
+        }
+
+
+    }
+
+    //populates the porttypes
+    private void populatePorttype(InformationHolder info,WSDLDescription description){
+        Map wsdlInterfaces = description.getWsdlInterfaces();
+        if (wsdlInterfaces!=null && !wsdlInterfaces.isEmpty()) {
+            if (wsdlInterfaces.size()>1){
+                //print warning - there are many interfaces. pick the first
+                System.out.println(CodegenMessages.getMessage("emitter.warningMultiplePorttypes"));
+            }
+            Iterator porttypeIterator = wsdlInterfaces.values().iterator();
+            info.setPorttype((WSDLInterface)porttypeIterator.next());
+        }
+    }
+
+    /**
+     * A simple class for keeping the information of the
+     * relevant service/port/binding/porttype combination
+     */
+    private class InformationHolder {
+
+        private WSDLService service;
+        private WSDLEndpoint port;
+        private WSDLBinding binding;
+        private WSDLInterface porttype;
+
+        public WSDLInterface getPorttype() {
+            return porttype;
+        }
+
+        public void setPorttype(WSDLInterface porttype) {
+            this.porttype = porttype;
+        }
+
+        public WSDLEndpoint getPort() {
+            return port;
+        }
+
+        public void setPort(WSDLEndpoint port) {
+            this.port = port;
+        }
+
+        public WSDLBinding getBinding() {
+            return binding;
+        }
+
+        public void setBinding(WSDLBinding binding) {
+            this.binding = binding;
+        }
+
+        public WSDLService getService() {
+            return service;
+        }
+
+        public void setService(WSDLService service) {
+            this.service = service;
+        }
+
+
     }
 }
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties Mon Jan  9 04:04:47 2006
@@ -65,5 +65,12 @@
 emitter.logEntryInterface4=2. CallbackHandler
 emitter.logEntryInterface5=3. Test Classes
 emitter.logEntryInterface6=4. Databinding Supporters
-emitter.SingleServiceMessage=Single service WSDL files only
+emitter.coreclassNameError=Cannot form the core class name
+emitter.serviceNotFoundError=specified service {0} not found
+emitter.endpointNotFoundError=specified end point {0} not found
+emitter.noEndpointsFoundError=endpoints not found
+emitter.warningMultipleServices=Warning - Multiple services found - picking the first service!
+emitter.warningMultipleEndpoints=Warning - Multiple endpoints found - picking the first endpoint!
+emitter.switchingMessages=Warning -No services found - switched to the interface mode!
+emitter.warningMultiplePorttypes=Warning - Found multiple porttypes - picking the first
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceTemplate.xsl Mon Jan  9 04:04:47 2006
@@ -1,5 +1,15 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
+
+     <!-- import the databinding template-->
+    <xsl:include href="databindsupporter"/>
+    <!-- import the other templates for databinding
+         Note  -  these names would be handled by a special
+         URI resolver during the xslt transformations
+     -->
+    <xsl:include href="externalTemplate"/>
+
+
     <xsl:template match="/interface">
     <xsl:variable name="isSync"><xsl:value-of select="@isSync"/></xsl:variable>
     <xsl:variable name="isAsync"><xsl:value-of select="@isAsync"/></xsl:variable>
@@ -73,6 +83,11 @@
 
         </xsl:if>
        </xsl:for-each>
+
+       <!-- Apply other templates --> 
+       //<xsl:apply-templates/>
        }
+
+
     </xsl:template>
    </xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/CommandLineOptionConstants.java Mon Jan  9 04:04:47 2006
@@ -34,6 +34,8 @@
     public static final String DATA_BINDING_TYPE_OPTION = "d";
     public static final String UNPACK_CLASSES_OPTION = "u";
     public static final String GENERATE_ALL_OPTION = "g";
+    public static final String PORT_NAME_OPTION = "pn";
+    public static final String SERVICE_NAME_OPTION = "sn";
 
      //long option constants
     public static final String OUTPUT_LOCATION_OPTION_LONG = "output";
@@ -47,6 +49,8 @@
     public static final String DATA_BINDING_TYPE_OPTION_LONG = "databinding-method";
     public static final String UNPACK_CLASSES_OPTION_LONG = "unpack-classes";
     public static final String GENERATE_ALL_OPTION_LONG = "generate-all";
+    public static final String PORT_NAME_OPTION_LONG = "port-name";
+    public static final String SERVICE_NAME_OPTION_LONG = "service-name";
 
 
     public static final String INVALID_OPTION = "INVALID_OPTION";

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/OptionValidator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/OptionValidator.java?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/OptionValidator.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/OptionValidator.java Mon Jan  9 04:04:47 2006
@@ -39,6 +39,8 @@
                     (DATA_BINDING_TYPE_OPTION).equalsIgnoreCase(optionType) ||
                     (UNPACK_CLASSES_OPTION).equalsIgnoreCase(optionType) ||
                     (GENERATE_ALL_OPTION).equalsIgnoreCase(optionType) ||
+                    (PORT_NAME_OPTION).equalsIgnoreCase(optionType) ||
+                    (SERVICE_NAME_OPTION).equalsIgnoreCase(optionType) ||
 
                     (OUTPUT_LOCATION_OPTION_LONG).equalsIgnoreCase(optionType) ||
                     (SERVER_SIDE_CODE_OPTION_LONG).equalsIgnoreCase(optionType) ||
@@ -50,6 +52,8 @@
                     (STUB_LANGUAGE_OPTION_LONG).equalsIgnoreCase(optionType) ||
                     (DATA_BINDING_TYPE_OPTION_LONG).equalsIgnoreCase(optionType) ||
                     (UNPACK_CLASSES_OPTION_LONG).equalsIgnoreCase(optionType) ||
+                    (PORT_NAME_OPTION_LONG).equalsIgnoreCase(optionType) ||
+                    (SERVICE_NAME_OPTION_LONG).equalsIgnoreCase(optionType) ||
                     (GENERATE_ALL_OPTION_LONG).equalsIgnoreCase(optionType)
             );
 

Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/WSDL2JavaTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/WSDL2JavaTest.java?rev=367284&r1=367283&r2=367284&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/WSDL2JavaTest.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/WSDL2JavaTest.java Mon Jan  9 04:04:47 2006
@@ -380,6 +380,11 @@
                 CommandLineOptionConstants.DATA_BINDING_TYPE_OPTION,
                 new CommandLineOption(CommandLineOptionConstants.DATA_BINDING_TYPE_OPTION,
                         new String[]{TestConstants.Databinding.XML_BEANS}));
+
+         optionMap.put(
+                CommandLineOptionConstants.GENERATE_ALL_OPTION,
+                new CommandLineOption(CommandLineOptionConstants.GENERATE_ALL_OPTION,
+                        new String[0]));
         //todo Make this work
         //test case option is on
 //        optionMap.put(

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=367284&r1=367283&r2=367284&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 Mon Jan  9 04:04:47 2006
@@ -407,7 +407,7 @@
             wsdlBindingOperation.setOperation(
                     wsdlInterface.getOperation(
                             wsdl4jBindingOperation.getOperation().getName()));
-            this.copyExtensibleElements(
+            copyExtensibleElements(
                     wsdl4jBindingOperation.getExtensibilityElements(),
                     wsdlBindingOperation, wsdl4jDefinition);
             wsdlBinding.addBindingOperation(wsdlBindingOperation);