axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl Wsdl2javaAntTask.java Wsdl2javaTestSuite.java
Date Tue, 11 Dec 2001 15:08:49 GMT
butek       01/12/11 07:08:49

  Modified:    java/src/org/apache/axis/wsdl Wsdl2java.java
               java/test/wsdl Wsdl2javaAntTask.java Wsdl2javaTestSuite.java
  Added:       java/src/org/apache/axis/wsdl/toJava BaseJavaType.java
                        BindingEntry.java CollectionType.java
                        DefinedType.java ElementType.java Emitter.java
                        JavaBindingWriter.java JavaComplexTypeWriter.java
                        JavaDefinitionWriter.java JavaDeployWriter.java
                        JavaEnumTypeWriter.java JavaFaultWriter.java
                        JavaHolderWriter.java JavaImplWriter.java
                        JavaInterfaceWriter.java JavaPortTypeWriter.java
                        JavaServiceImplWriter.java JavaServiceWriter.java
                        JavaSkelWriter.java JavaStubWriter.java
                        JavaTestCaseWriter.java JavaTypeWriter.java
                        JavaUndeployWriter.java JavaWriter.java
                        JavaWriterFactory.java MessageEntry.java
                        Namespaces.java NoopWriter.java Parameter.java
                        Parameters.java PortTypeEntry.java RefdType.java
                        SchemaUtils.java ServiceEntry.java SymTabEntry.java
                        SymbolTable.java Type.java Utils.java Writer.java
                        WriterFactory.java
  Removed:     java/src/org/apache/axis/wsdl BaseJavaType.java
                        BindingEntry.java CollectionType.java
                        DefinedType.java ElementType.java Emitter.java
                        JavaBindingWriter.java JavaComplexTypeWriter.java
                        JavaDefinitionWriter.java JavaDeployWriter.java
                        JavaEnumTypeWriter.java JavaFaultWriter.java
                        JavaHolderWriter.java JavaImplWriter.java
                        JavaInterfaceWriter.java JavaPortTypeWriter.java
                        JavaServiceImplWriter.java JavaServiceWriter.java
                        JavaSkelWriter.java JavaStubWriter.java
                        JavaTestCaseWriter.java JavaTypeWriter.java
                        JavaUndeployWriter.java JavaWriter.java
                        JavaWriterFactory.java MessageEntry.java
                        Namespaces.java NoopWriter.java Parameter.java
                        Parameters.java PortTypeEntry.java RefdType.java
                        SchemaUtils.java ServiceEntry.java SymTabEntry.java
                        SymbolTable.java Type.java Utils.java Writer.java
                        WriterFactory.java
  Log:
  Moved most org.apache.axis.wsdl stuff to org.apache.axis.wsdl.toJava with the
  exception of Wsdl2java which stays but becomes WSDL2Java.
  
  NOTE:  since I'm on a windows platform, the name of the Wsdl2java file won't
  change with this commit.  Sam offerred to do the remove/add from linux.  So until he
  does, this will not build.
  
  Revision  Changes    Path
  1.24      +7 -4      xml-axis/java/src/org/apache/axis/wsdl/Wsdl2java.java
  
  Index: Wsdl2java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Wsdl2java.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Wsdl2java.java	2001/12/06 13:47:32	1.23
  +++ Wsdl2java.java	2001/12/11 15:08:47	1.24
  @@ -61,6 +61,9 @@
   
   import org.apache.axis.utils.JavaUtils;
   
  +import org.apache.axis.wsdl.toJava.Emitter;
  +import org.apache.axis.wsdl.toJava.JavaWriterFactory;
  +
   import java.util.HashMap;
   import java.util.List;
   
  @@ -69,7 +72,7 @@
    *
    * @author Tom Jordahl (tjordahl@macromedia.com)
    */
  -public class Wsdl2java {
  +public class WSDL2Java {
       // Define our short one-letter option identifiers.
       protected static final int HELP_OPT = 'h';
       protected static final int VERBOSE_OPT = 'v';
  @@ -269,14 +272,14 @@
       private static void printUsage() {
           String lSep = System.getProperty("line.separator");
           StringBuffer msg = new StringBuffer();
  -        msg.append("Wsdl2java " +
  +        msg.append("WSDL2Java " +
                   JavaUtils.getMessage("emitter00")).append(lSep);
           msg.append(
                   JavaUtils.getMessage("usage00",
  -                "java " + Wsdl2java.class.getName() + " [options] WSDL-URI"))
  +                "java " + WSDL2Java.class.getName() + " [options] WSDL-URI"))
                   .append(lSep);
           msg.append(JavaUtils.getMessage("options00")).append(lSep);
  -        msg.append(CLUtil.describeOptions(Wsdl2java.options).toString());
  +        msg.append(CLUtil.describeOptions(WSDL2Java.options).toString());
           System.out.println(msg.toString());
           System.exit(1);
       }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/BaseJavaType.java
  
  Index: BaseJavaType.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  
  /**
   * This Type is for a QName represents a Base Java Type (i.e. xsd:string) 
   */
  public class BaseJavaType extends Type {
      public BaseJavaType(QName pqName) {
          super(pqName);
      }
  };
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/BindingEntry.java
  
  Index: BindingEntry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import java.util.HashMap;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Operation;
  import javax.wsdl.QName;
  
  /**
  * This class represents a WSDL binding.  It encompasses the WSDL4J Binding object so it can
  * reside in the SymbolTable.  It also adds a few bits of information that are a nuisance to get
  * from the WSDL4J Binding object:  binding type, binding style, input/output/fault body types.
  */
  public class BindingEntry extends SymTabEntry {
      // Binding styles
      public static final int STYLE_RPC = 0;
      public static final int STYLE_DOCUMENT = 1;
  
      // Binding types
      public static final int TYPE_SOAP = 0;
      public static final int TYPE_HTTP_GET = 1;
      public static final int TYPE_HTTP_POST = 2;
      public static final int TYPE_UNKNOWN = 3;
  
      // Binding Operation use types
      public static final int USE_ENCODED = 0;
      public static final int USE_LITERAL = 1;
  
      private Binding binding;
      private int     bindingType;
      private int     bindingStyle;
      private HashMap attributes;
  
      /**
       * Construct a BindingEntry from a WSDL4J Binding object and the additional binding info:
       * binding type, binding style, and the attributes which contain the input/output/fault body
       * type information.
       */
      public BindingEntry(Binding binding, int bindingType, int bindingStyle, HashMap attributes) {
          super(binding.getQName());
          this.binding = binding;
          this.bindingType = bindingType;
          this.bindingStyle = bindingStyle;
          this.attributes = attributes;
      } // ctor
  
      /**
       * Get this entry's WSDL4J Binding object.
       */
      public Binding getBinding() {
          return binding;
      } // getBinding
  
      /**
       * Get this entry's binding type.  One of BindingEntry.TYPE_SOAP, BindingEntry.TYPE_HTTP_GET,
       * BindingEntry.TYPE_HTTP_POST.
       */
      public int getBindingType() {
          return bindingType;
      } // getBindingType
  
      /**
       * Get this entry's binding style.  One of BindingEntry.STYLE_RPC, BindingEntry.STYLE_DOCUMENT.
       */
      public int getBindingStyle() {
          return bindingStyle;
      } // getBindingStyle
  
      /**
       * Get the input body type for the given operation.  One of BindingEntry.USE_ENCODED,
       * BindingEntry.USE_LITERAL.
       */
      public int getInputBodyType(Operation operation) {
          OperationAttr attr = (OperationAttr) attributes.get(operation);
          if (attr == null) {
              return USE_ENCODED; // should really create an exception for this.
          }
          else {
              return attr.getInputBodyType();
          }
      } // getInputBodyType
  
      /**
       * Get the output body type for the given operation.  One of BindingEntry.USE_ENCODED,
       * BindingEntry.USE_LITERAL.
       */
      public int getOutputBodyType(Operation operation) {
          OperationAttr attr = (OperationAttr) attributes.get(operation);
          if (attr == null) {
              return USE_ENCODED; // should really create an exception for this.
          }
          else {
              return attr.getOutputBodyType();
          }
      } // getOutputBodyType
  
      /**
       * Get the fault body type for the given fault of the given operation.  One of
       * BindingEntry.USE_ENCODED, BindingEntry.USE_LITERAL.
       */
      public int getFaultBodyType(Operation operation, String faultName) {
          OperationAttr attr = (OperationAttr) attributes.get(operation);
          if (attr == null) {
              return 0; // should really create an exception for this.
          }
          else {
              HashMap m = attr.getFaultBodyTypeMap();
  
              // Default to encoded if we didn't have a soap:body for the fault
              if ( ! m.containsKey(faultName) ) {
                  return USE_ENCODED;
              }
  
              return ((Integer) m.get(faultName)).intValue();
          }
      }
  
      /**
       * Contains attributes for Operations
       *  - Body type: encoded or literal
       */
      protected static class OperationAttr {
          private int inputBodyType;
          private int outputBodyType;
          private HashMap faultBodyTypeMap;
  
          public OperationAttr(int inputBodyType, int outputBodyType, HashMap faultBodyTypeMap) {
              this.inputBodyType = inputBodyType;
              this.outputBodyType = outputBodyType;
              this.faultBodyTypeMap = faultBodyTypeMap;
          }
  
          public int getInputBodyType() {
              return inputBodyType;
          }
  
          public int getOutputBodyType() {
              return outputBodyType;
          }
  
          public HashMap getFaultBodyTypeMap() {
              return faultBodyTypeMap;
          }
      } // class OperationAttr
  
  } // class BindingEntry
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/CollectionType.java
  
  Index: CollectionType.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  /**
   * This Type is for a QName that is a 'collection'.
   * For example,
   *   <element name="foo" type="bar" maxOccurs="unbounded" />
   * We need a way to indicate in the symbol table that a foo is
   * 'collection of bars',  In such cases a collection type is 
   * added with the special QName  <name>[<minOccurs>, <maxOccurs>]
   */
  public class CollectionType extends DefinedType {
      public CollectionType(QName pqName, String pjName, Node pNode) {
          super(pqName, pjName, pNode);
  
          // Initially these CollectionTypes are not emitted.  This may change.
          setShouldEmit(false); 
      }
  };
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/DefinedType.java
  
  Index: DefinedType.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  /**
   * This Type is for a QName that is a complex or simple type, these types are 
   * always emitted.
   */
  public class DefinedType extends Type {
      public DefinedType(QName pqName, String pjName, Node pNode) {
          super(pqName, pjName, pNode);
          setShouldEmit(true);
      }
  };
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/ElementType.java
  
  Index: ElementType.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  
  /**
   * This Type is for a QName that is an element, these types are only emitted if 
   * referenced by a ref= or an element=.
   * An element type can be defined inline or it can be defined via
   * a ref/type attribute.
   */
  public class ElementType extends Type {
      private boolean definedDirectly;
      /**
       * Create an element type defined by a ref/type attribute
       */
      public ElementType(QName pqName, Type refType, Node pNode) {
          super(pqName, refType, pNode);
          setShouldEmit(false);  // No need to emit since code will use ref info
          definedDirectly = false;
      };
      /**
       * Create an element type defined directly.               
       */
      public ElementType(QName pqName, String pjName, Node pNode) {
          super(pqName, pjName, pNode);
          setShouldEmit(false);  // Only emit if refd
          definedDirectly = true;
      }
      public boolean getDefinedDirectly() {return definedDirectly;}
  };
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.XMLUtils;
  import org.w3c.dom.Document;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Definition;
  import javax.wsdl.Message;
  import javax.wsdl.PortType;
  import javax.wsdl.Service;
  import javax.wsdl.WSDLException;
  import javax.wsdl.factory.WSDLFactory;
  import javax.wsdl.xml.WSDLReader;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.ResourceBundle;
  import java.util.Vector;
  
  /**
   * This class produces java files for stubs, skeletons, and types from a
   * WSDL document.
   *
   * @author Russell Butek (butek@us.ibm.com)
   * @author Tom Jordahl (tjordahl@macromedia.com)
   * @author Steve Graham (sggraham@us.ibm.com)
   */
  public class Emitter {
      // Scope constants
      public static final byte NO_EXPLICIT_SCOPE = 0x00;
      public static final byte APPLICATION_SCOPE = 0x01;
      public static final byte REQUEST_SCOPE     = 0x10;
      public static final byte SESSION_SCOPE     = 0x11;
  
      protected Document doc = null;
      protected Definition def = null;
      protected boolean bDebug = false;
      protected boolean bEmitSkeleton = false;
      protected boolean bEmitTestCase = false;
      protected boolean bVerbose = false;
      protected boolean bGenerateImports = true;
      protected String outputDir = null;
      protected String packageName = null;
      protected byte scope = NO_EXPLICIT_SCOPE;
      protected ArrayList classList = new ArrayList();
      protected ArrayList fileList = new ArrayList();
      protected Namespaces namespaces = null;
      protected HashMap delaySetMap = null;
      protected WriterFactory writerFactory = null;
      protected SymbolTable symbolTable = null;
  
      /**
       * Default constructor.
       */
      public Emitter(WriterFactory writerFactory) {
          this.writerFactory = writerFactory;
      } // ctor
  
      /**
       * Call this method if you have a uri for the WSDL document
       */
      public void emit(String uri) throws IOException, WSDLException {
          if (bVerbose)
              System.out.println(JavaUtils.getMessage("parsing00", uri));
  
          emit(XMLUtils.newDocument(uri));
      } // emit
  
      /**
       * Call this method if your WSDL document has already been parsed as an XML DOM document.
       */
      public void emit(Document doc) throws IOException, WSDLException {
          WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
          reader.setVerbose(bVerbose);
          def = reader.readWSDL(null, doc);
          this.doc = doc;
          namespaces = new Namespaces(outputDir);
  
          if (packageName != null) {
               namespaces.setDefaultPackage(packageName);
          } else {
              // First, read the namespace mapping file - NStoPkg.properties - if it
              // exists, and load the namespaceMap HashMap with its data.
              getNStoPkgFromPropsFile(namespaces);
              
              if (delaySetMap != null) {
                  namespaces.putAll(delaySetMap);
              }
          }
  
          symbolTable = new SymbolTable(namespaces, bGenerateImports, bDebug);
          symbolTable.add(def, doc);
          writerFactory.writerPass(def, symbolTable);
          if (bDebug) {
              symbolTable.dump(System.out);
          }
          emit(def, doc);
  
          // Output extra stuff (deployment files and faults) 
          // outside of the recursive emit method.
          Writer writer = writerFactory.getWriter(def, symbolTable);
          writer.write();
      } // emit
  
      private void emit(Definition def, Document doc) throws IOException, WSDLException {
          // Output Java classes for types
          writeTypes();
  
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                  Writer writer = null;
                  if (entry instanceof MessageEntry) {
                      writer = writerFactory.getWriter(
                              ((MessageEntry) entry).getMessage(), symbolTable);
                  }
                  else if (entry instanceof PortTypeEntry) {
                      PortTypeEntry pEntry = (PortTypeEntry) entry;
                      // If the portType is undefined, then we're parsing a Definition
                      // that didn't contain a portType, merely a binding that referred
                      // to a non-existent port type.  Don't bother writing it.
                      if (pEntry.getPortType().isUndefined()) {
                          continue;
                      }
                      writer = writerFactory.getWriter(pEntry.getPortType(),
                              symbolTable);
                  }
                  else if (entry instanceof BindingEntry) {
                      BindingEntry bEntry = (BindingEntry)entry;
                      Binding binding = bEntry.getBinding();
  
                      // If the binding is undefined, then we're parsing a Definition
                      // that didn't contain a binding, merely a service that referred
                      // to a non-existent binding.  Don't bother writing it.
                      // If this isn't a SOAP binding, don't bother writing it, either.
                      if (binding.isUndefined() ||
                          bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                          continue;
                      }
                      writer = writerFactory.getWriter(binding, symbolTable);
                  }
                  else if (entry instanceof ServiceEntry) {
                      writer = writerFactory.getWriter(
                              ((ServiceEntry) entry).getService(), symbolTable);
                  }
                  if (writer != null) {
                      writer.write();
                  }
              }
          }
      } // emit
  
      /**
       * Look for a NStoPkg.properties file in the CLASSPATH.  If it exists,
       * then collect the namespace->package mappings from it.
       */
      private static void getNStoPkgFromPropsFile(HashMap namespaces)
      {
          try {
              ResourceBundle mappings = ResourceBundle.getBundle("NStoPkg");
              Enumeration keys = mappings.getKeys();
              while (keys.hasMoreElements()) {
                  try {
                      String key = (String) keys.nextElement();
                      namespaces.put(key, mappings.getString(key));
                  }
                  catch (Throwable t) {
                  }
              }
          }
          catch (Throwable t) {
          }
      } // getNStoPkgFromPropsFile
  
      ///////////////////////////////////////////////////
      //
      // Command line switches
      //
  
      /**
       * Turn on/off server skeleton creation
       * @param boolean value
       */
      public void generateSkeleton(boolean value) {
          this.bEmitSkeleton = value;
      }
  
      /**
       * Indicate if we should be emitting server side code and deploy/undeploy
       */ 
      public boolean getGenerateSkeleton() {
          return bEmitSkeleton;
      }
  
      /**
       * Turn on/off test case creation
       * @param boolean value
       */
      public void generateTestCase(boolean value) {
          this.bEmitTestCase = value;
      }
  
      /**
       * Return the current definition
       */ 
      public Definition getCurrentDefinition() {
          return this.def;
      }
      
      /**
       * Turn on/off generation of elements from imported files.
       * @param boolean generateImports
       */
      public void generateImports(boolean generateImports) {
          this.bGenerateImports = generateImports;
      } // generateImports
  
      /**
       * Turn on/off debug messages.
       * @param boolean value
       */
      public void debug(boolean value) {
          bDebug = value;
      } // debug
  
      /**
       * Return the status of the debug switch.
       */
      public boolean getDebug() {
          return bDebug;
      } // getDebug
  
      /**
       * Turn on/off verbose messages
       * @param boolean value
       */
      public void verbose(boolean value) {
          this.bVerbose = value;
      }
  
      /**
       * Return the status of the verbose switch
       */ 
      public boolean getVerbose() {
          return this.bVerbose;
      }
  
      /**
       * Set a map of namespace -> Java package names
       */ 
      public void setNamespaceMap(HashMap map) {
          delaySetMap = map;
      }
  
  
      /**
       * Set the output directory to use in emitted source files
       */
      public void setOutputDir(String outputDir) {
          this.outputDir = outputDir;
      }
  
      /**
       * Get global package name to use instead of mapping namespaces
       */ 
      public String getPackageName() {
          return packageName;
      }
  
      /**
       * Set a global package name to use instead of mapping namespaces
       */ 
      public void setPackageName(String packageName) {
          this.packageName = packageName;
      }
      
      /**
       * Get the output directory to use for emitted source files
       */
      public String getOutputDir() {
          return this.outputDir;
      }
      
      /**
       * Set the scope for the deploy.xml file.
       * @param scope One of Emitter.NO_EXPLICIT_SCOPE, Emitter.APPLICATION_SCOPE, Emitter.REQUEST_SCOPE, Emitter.SESSION_SCOPE.  Anything else is equivalent to NO_EXPLICIT_SCOPE and no explicit scope tag will appear in deploy.xml.
       */
      public void setScope(byte scope) {
          this.scope = scope;
      } // setScope
  
      /**
       * Get the scope for the deploy.xml file.
       */
      public byte getScope() {
          return scope;
      } // getScope
  
      ///////////////////////////////////////////////////
      //
      // Implementation
      //
  
      /**
       * This method returns a list of all generated class names.
       */
      public List getGeneratedClassNames() {
          return this.classList;
      }
  
      /**
       * This method returns a list of all generated file names.
       */
      public List getGeneratedFileNames() {
          return this.fileList;
      }
  
      //////////////////////////////
      //
      // Methods using types (non WSDL)
      //
  
      /**
       * Generate bindings (classes and class holders) for the complex types.
       * If generating serverside (skeleton) spit out beanmappings
       */
      protected void writeTypes() throws IOException {
          Vector types = symbolTable.getTypes();
          for (int i = 0; i < types.size(); ++i) {
              Type type = (Type) types.elementAt(i);
              if (type.isDefined() && type.getShouldEmit() && type.getBaseType() == null) {
                  Writer writer = writerFactory.getWriter(type, symbolTable);
                  writer.write();
              }
          }
      } // writeTypes
  
      //
      // Methods using types (non WSDL)
      //
      //////////////////////////////
  
      ///////////////////////////////////////////////////
      //
      // Utility methods
      //
  
      public Namespaces getNamespaces() {
          return namespaces;
      } // getNamespaces
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBindingWriter.java
  
  Index: JavaBindingWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  
  import javax.wsdl.Binding;
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's Binding Writer.  It writes the following files, as appropriate:
  * <bindingName>Stub.java, <bindingName>Skeleton.java, <bindingName>Impl.java.
  */
  public class JavaBindingWriter implements Writer {
      Writer stubWriter = null;
      Writer skelWriter = null;
      Writer implWriter = null;
  
      /**
       * Constructor.
       */
      public JavaBindingWriter(
              Emitter emitter,
              Binding binding,
              SymbolTable symbolTable) {
          BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
          if (bEntry.isReferenced()) {
              stubWriter = new JavaStubWriter(emitter, bEntry, symbolTable);
              if (emitter.bEmitSkeleton) {
                  skelWriter = new JavaSkelWriter(emitter, bEntry, symbolTable);
                  String fileName = Utils.getJavaLocalName(bEntry.getName())
                          + "Impl.java";
                  try {
                  // NOTE:  Where does the fileExists method really belong?
                      if (!((JavaWriter) stubWriter).fileExists (fileName,
                              binding.getQName().getNamespaceURI())) {
                          implWriter = new JavaImplWriter(
                                  emitter, bEntry, symbolTable);
                      }
                  }
                  catch (IOException ioe) {
                      System.err.println(
                              JavaUtils.getMessage("fileExistError00", fileName));
                  }
              }
          }
      } // ctor
  
      /**
       * Write all the binding bindnigs:  stub, skeleton, and impl.
       */
      public void write() throws IOException {
          if (stubWriter != null) {
              stubWriter.write();
          }
          if (skelWriter != null) {
              skelWriter.write();
          }
          if (implWriter != null) {
              implWriter.write();
          }
      } // write
  
  } // class JavaBindingWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaComplexTypeWriter.java
  
  Index: JavaComplexTypeWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Vector;
  
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  import org.w3c.dom.Node;
  
  /**
  * This is Wsdl2java's Complex Type Writer.  It writes the <typeName>.java file.
  */
  public class JavaComplexTypeWriter extends JavaWriter {
      private Type type;
      private Vector elements;
      private Type extendType;  
  
      /**
       * Constructor.
       * @param emitter   
       * @param type        The type representing this class
       * @param elements    Vector containing the Type and name of each property
       * @param extendType  The type representing the extended class (or null)
       */
      protected JavaComplexTypeWriter(
              Emitter emitter,
              Type type, Vector elements, Type extendType) {
          super(emitter, type, "", "java",
                  JavaUtils.getMessage("genType00"));
          this.type = type;
          this.elements = elements;
          this.extendType = extendType;
      } // ctor
  
     /**
       * Generate the binding for the given complex type.
       * The elements vector contains the Types (even indices) and
       * element names (odd indices) of the contained elements
       */
      protected void writeFileBody() throws IOException {
          Node node = type.getNode();
  
          // See if this class extends another class
          String extendsText = "";
          if (extendType != null) {
              extendsText = " extends " + extendType.getJavaName() + " ";
          }
  
          // We are only interested in the java names of the types, so replace the
          // Types in the list with their java names.  
          // Also filter element names for Java 
          for (int i=0; i < elements.size(); i+=2) {
              elements.setElementAt(((Type) elements.get(i)).getJavaName(), i);
              elements.setElementAt( Utils.xmlNameToJava((String) elements.get(i + 1)), i + 1);
          }
  
          pw.println("public class " + className + extendsText + " implements java.io.Serializable {");
  
          for (int i = 0; i < elements.size(); i += 2) {
              String variable = (String) elements.get(i + 1);
              pw.println("    private " + elements.get(i) + " " + variable + ";");
          }
  
          pw.println();
          pw.println("    public " + className + "() {");
          pw.println("    }");
          pw.println();
          if (elements.size() > 0) {
              pw.print("    public " + className + "(");
              for (int i = 0; i < elements.size(); i += 2) {
                  if (i != 0) pw.print(", ");
                  String variable = (String) elements.get(i + 1);
                  pw.print((String) elements.get(i) + " " + variable);
              }
              pw.println(") {");
              for (int i = 1; i < elements.size(); i += 2) {
                  String variable = (String) elements.get(i);
                  pw.println("        this." + variable + " = " + variable + ";");
              }
              pw.println("    }");
          }
          pw.println();
          for (int i = 0; i < elements.size(); i += 2) {
              String typeName = (String) elements.get(i);
              String name = (String) elements.get(i + 1);
              String capName = Utils.capitalizeFirstChar(name);
  
              pw.println("    public " + typeName + " get" + capName + "() {");
              pw.println("        return " + name + ";");
              pw.println("    }");
              pw.println();
              pw.println("    public void set" + capName + "(" + typeName + " " + name + ") {");
              pw.println("        this." + name + " = " + name + ";");
              pw.println("    }");
              pw.println();
          }
          pw.println("}");
          pw.close();
      } // writeOperation
  
  } // class JavaComplexTypeWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDefinitionWriter.java
  
  Index: JavaDefinitionWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Definition;
  import javax.wsdl.Fault;
  import javax.wsdl.Operation;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  /**
   * This is Wsdl2java's Definition Writer.  
   * It currently writes the following files:
   *   deploy.xml, undeploy.xml and Faults as needed.
   */
  public class JavaDefinitionWriter implements Writer {
      Writer deployWriter = null;
      Writer undeployWriter = null;
      Emitter emitter;
      Definition definition;
      SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      public JavaDefinitionWriter(Emitter emitter, Definition definition,
              SymbolTable symbolTable) {
          deployWriter = new JavaDeployWriter(emitter, definition, symbolTable);
          undeployWriter = new JavaUndeployWriter(emitter, definition, symbolTable);
          this.emitter = emitter;
          this.definition = definition;
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write other items from the definition as needed.
       */
      public void write() throws IOException {
          if (emitter.getGenerateSkeleton()) {
              deployWriter.write();
              undeployWriter.write();
          }
          writeFaults();
      } // write
  
      /**
       * Write all the faults.
       * 
       * The fault name is derived from the fault message name per JAX-RPC
       */
      private void writeFaults() throws IOException {
          HashSet faults = new HashSet();
          Vector faultList = new Vector();
          Map portTypes = definition.getPortTypes();
          Iterator pti = portTypes.values().iterator();
          // collect referenced faults in a list
          while (pti.hasNext()) {
              PortType portType = (PortType) pti.next();
              
              // Don't emit faults that are not referenced.
              if (!(symbolTable.getPortTypeEntry(portType.getQName())).isReferenced()) {
                  continue;
              }
              
              List operations = portType.getOperations();
              for (int i = 0; i < operations.size(); ++i) {
                  Operation operation = (Operation) operations.get(i);
                  Map opFaults = operation.getFaults();
                  Iterator fi = opFaults.values().iterator();
                  while (fi.hasNext()) {
                      Fault f = (Fault) fi.next();
                      String name = Utils.getExceptionName(f);
                      // prevent duplicates
                      if (! faultList.contains(name) ) {
                          faultList.add(name);
                          faults.add(f);  // add this fault to the list
                      }
                  }
              }
          }
          
          // iterate over fault list, emitting code.
          Iterator fi = faults.iterator();
          while (fi.hasNext()) {
              Fault fault = (Fault) fi.next();
              String exceptionName = Utils.getExceptionName(fault);
              QName faultQName = new QName(definition.getTargetNamespace(), exceptionName);
              new JavaFaultWriter(emitter, faultQName, fault, symbolTable).write();
          }
      } // writeFaults
  
  } // class JavaDefinitionWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Binding;
  import javax.wsdl.BindingOperation;
  import javax.wsdl.Definition;
  import javax.wsdl.Port;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's deploy Writer.  It writes the deploy.java file.
  */
  public class JavaDeployWriter extends JavaWriter {
      private Definition definition;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaDeployWriter(Emitter emitter, Definition definition, SymbolTable symbolTable) {
          super(emitter,
                  new QName(definition.getTargetNamespace(), "deploy"),
                  "",
                  "wsdd",
                  JavaUtils.getMessage("genDeploy00"));
          this.definition = definition;
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Replace the default file header with the deployment doc file header.
       */
      protected void writeFileHeader() throws IOException {
          initializeDeploymentDoc("deploy");
      } // writeFileHeader
  
      /**
       * Write the body of the deploy.xml file.
       */
      protected void writeFileBody() throws IOException {
          writeDeployServices();
          writeDeployTypes();
          pw.println("</deployment>");
          pw.close();
      } // writeFileBody
  
      /**
       * Write out deployment and undeployment instructions for each WSDL service
       */
      private void writeDeployServices() throws IOException {
          //deploy the ports on each service
          Map serviceMap = definition.getServices();
          for (Iterator mapIterator = serviceMap.values().iterator(); mapIterator.hasNext();) {
              Service myService = (Service) mapIterator.next();
  
              pw.println();
              pw.println("  <!-- " + JavaUtils.getMessage(
                      "wsdlService00", myService.getQName().getLocalPart())
                      + " -->");
              pw.println();
  
              for (Iterator portIterator = myService.getPorts().values().iterator(); portIterator.hasNext();) {
                  Port myPort = (Port) portIterator.next();
                  writeDeployPort(myPort);
              }
          }
      } //writeDeployServices
  
      /**
       * Write out bean mappings for each type
       */
      private void writeDeployTypes() throws IOException {
          Vector types = symbolTable.getTypes();
  
          pw.println();
          for (int i = 0; i < types.size(); ++i) {
              Type type = (Type) types.elementAt(i);
              if (type.getBaseType() == null && type.isReferenced() && type.getShouldEmit()) {
                  pw.println("  <beanMapping");
                  pw.println("    xmlns:ns=\"" + type.getQName().getNamespaceURI() + "\"");
                  pw.println("    qname=\"ns:" + type.getQName().getLocalPart() + '"');
                  pw.println("    languageSpecificType=\"java:" + type.getJavaName() + '"');
                  pw.println("  />");
              }
          }
      } //writeDeployTypes
  
      /**
       * Write out deployment and undeployment instructions for given WSDL port
       */
      private void writeDeployPort(Port port) throws IOException {
          Binding binding = port.getBinding();
          BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
          String serviceName = port.getName();
  
          boolean isRPC = (bEntry.getBindingStyle() == BindingEntry.STYLE_RPC);
  
          pw.println("  <service name=\"" + serviceName
                  + "\" provider=\"" + (isRPC ? "java:RPC" : "java:MSG") + "\">");
  
          writeDeployBinding(binding);
  
          pw.println("  </service>");
      } //writeDeployPort
  
      /**
       * Write out deployment instructions for given WSDL binding
       */
      private void writeDeployBinding(Binding binding) throws IOException {
          BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
          pw.println("      <parameter name=\"className\" value=\""
                           + bEntry.getName() + "Skeleton" + "\"/>");
  
          String methodList = "";
          Iterator operationsIterator = binding.getBindingOperations().iterator();
          for (; operationsIterator.hasNext();) {
              BindingOperation op = (BindingOperation) operationsIterator.next();
              methodList = methodList + " " + op.getName();
          }
  
          pw.println("      <parameter name=\"methodName\" value=\"" + methodList + "\"/>");
  
          if (emitter.getScope() == Emitter.APPLICATION_SCOPE) {
              pw.println("      <parameter name=\"scope\" value=\"Application\"/>");
          }
          else if (emitter.getScope() == Emitter.REQUEST_SCOPE) {
              pw.println("      <parameter name=\"scope\" value=\"Request\"/>");
          }
          else if (emitter.getScope() == Emitter.SESSION_SCOPE) {
              pw.println("      <parameter name=\"scope\" value=\"Session\"/>");
          }
      } //writeDeployBinding
  
  } // class JavaDeployWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java
  
  Index: JavaEnumTypeWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Vector;
  
  import org.apache.axis.utils.JavaUtils;
  
  import org.w3c.dom.Node;
  
  /**
  * This is Wsdl2java's Complex Type Writer.  It writes the <typeName>.java file.
  */
  public class JavaEnumTypeWriter extends JavaWriter {
      private Type type;
      private Vector elements;
  
      /**
       * Constructor.
       */
      protected JavaEnumTypeWriter(
              Emitter emitter,
              Type type, Vector elements) {
          super(emitter, type, "", "java",
                  JavaUtils.getMessage("genType00"));
          this.type = type;
          this.elements = elements;
      } // ctor
  
     /**
       * Generate the binding for the given enumeration type.
       * The values vector contains the base type (first index) and
       * the values (subsequent Strings)
       */
      protected void writeFileBody() throws IOException {
          Node node = type.getNode();
  
          // The first index is the base type.  Get its java name.
          String baseType = ((Type) elements.get(0)).getJavaName();
          String javaName = Utils.getJavaLocalName(type.getName());
  
          // Note:
          // The current JAX-RPC spec indicates that enumeration is supported for all simple types.
          // However, the mapping in JAX-RPC will only work for Strings :-)
          // I am sure that the JAX-RPC mapping will change -or- the JAX-RPC spec will be changed to 
          // support only the enumeration of Strings.
          // The current state of the AXIS code only supports enumerations of Strings.  If JAX-RPC
          // does introduce new bindings, changes will be required in this method, in EnumSerialization,
          // and in JavaTypeWriter.getEnumerationBaseAndValues.
          pw.println("public class " + javaName + " implements java.io.Serializable {");
  
          // Each object has a private _value_ variable to store the base value
          pw.println("    private " + baseType + " _value_;");
  
          // The enumeration values are kept in a hashtable
          pw.println("    private static java.util.HashMap _table_ = new java.util.HashMap();");
          pw.println("");
  
          // A protected constructor is used to create the static enumeration values
          pw.println("    // " + JavaUtils.getMessage("ctor00"));
          pw.println("    protected " + javaName + "(" + baseType + " value) {");
          pw.println("        _value_ = value;");
          pw.println("        _table_.put(_value_,this);");
          pw.println("    };");
          pw.println("");
  
          // A public static variable of the base type is generated for each enumeration value.
          // Each variable is preceded by an _.
          for (int i=1; i < elements.size(); i++) {
              pw.println("    public static final " + baseType + " _" + elements.get(i)
                             + " = \"" + elements.get(i) + "\";");
          }
  
          // A public static variable is generated for each enumeration value.
          for (int i=1; i < elements.size(); i++) {
              String variable = (String) elements.get(i);
              if (JavaUtils.isJavaKeyword(variable)) {
                  variable = JavaUtils.makeNonJavaKeyword(variable);
              }
              pw.println("    public static final " + javaName + " " + variable
                             + " = new " + javaName + "(_" + elements.get(i) + ");");
          }
          // Getter that returns the base value of the enumeration value
          pw.println("    public " + baseType+ " getValue() { return _value_;}");
  
          // FromValue returns the unique enumeration value object from the table
          pw.println("    public static " + javaName+ " fromValue(" + baseType +" value)");
          pw.println("          throws java.lang.IllegalStateException {");
          pw.println("        "+javaName+" enum = ("+javaName+")_table_.get(value);");
          pw.println("        if (enum==null) throw new java.lang.IllegalStateException();");
          pw.println("        return enum;");
          pw.println("    }");
  
          // Equals == to determine equality  value
          pw.println("    public boolean equals(Object obj) {return (obj == this);}");
  
          // Provide a reasonable hashCode method             
          pw.println("    public int hashCode() { return _value_.hashCode();}");
  
          // Provide a reasonable toString method.
          pw.println("    public String toString() { return _value_;}");
          pw.println("}");
  
          pw.close();
      } // writeOperation
  
  } // class JavaEnumTypeWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaFaultWriter.java
  
  Index: JavaFaultWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Vector;
  
  import javax.wsdl.Fault;
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's Fault Writer.  It writes the <faultName>.java file.
  * NOTE:  this must be rewritten.  It doesn't follow JAX-RPC.
  */
  public class JavaFaultWriter extends JavaWriter {
      private Fault fault;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaFaultWriter(Emitter emitter, QName qname, Fault fault, SymbolTable symbolTable) {
          super(emitter, qname, "", "java", JavaUtils.getMessage("genFault00"));
          this.fault = fault;
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the body of the Fault file.
       */
      protected void writeFileBody() throws IOException {
          pw.println("public class " + className + " extends org.apache.axis.AxisFault {");
  
          Vector params = new Vector();
  
          symbolTable.partStrings(params, fault.getMessage().getOrderedParts(null));
  
          // Write data members of the exception and getter methods for them
          for (int i = 0; i < params.size(); i += 2) {
              String type = ((Type) params.get(i)).getName();
              String variable = (String) params.get(i + 1);
              pw.println("    public " + type + " " + variable + ";");
              pw.println("    public " + type + " get" + Utils.capitalizeFirstChar(variable) + "() {");
              pw.println("        return this." + variable + ";");
              pw.println("    }");
          }
  
          // Default contructor
          pw.println();
          pw.println("    public " + className + "() {");
          pw.println("    }");
          pw.println();
          
          // contructor that initializes data
          if (params.size() > 0) {
              pw.print("      public " + className + "(");
              for (int i = 0; i < params.size(); i += 2) {
                  if (i != 0) pw.print(", ");
                  pw.print(((Type) params.get(i)).getName() + " " + params.get(i + 1));
              }
              pw.println(") {");
              for (int i = 1; i < params.size(); i += 2) {
                  String variable = (String) params.get(i);
  
                  pw.println("        this." + variable + " = " + variable + ";");
              }
              pw.println("    }");
          }
          
          // Done with class
          pw.println("}");
          pw.close();
      } // writeFileBody
  
  } // class JavaFaultWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaHolderWriter.java
  
  Index: JavaHolderWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's Holder Writer.  It writes the <typeName>Holder.java file.
  */
  public class JavaHolderWriter extends JavaWriter {
      private Type type;
  
      /**
       * Constructor.
       */
      protected JavaHolderWriter(Emitter emitter, Type type) {
          super(emitter, type, "Holder", "java",
                  JavaUtils.getMessage("genHolder00"));
          this.type = type;
      } // ctor
  
      /**
       * Generate the holder for the given complex type.
       */
      protected void writeFileBody() throws IOException {
          String holderType = Utils.getJavaLocalName(type.getName());
          pw.println("public final class " + className + " implements java.io.Serializable {");
          pw.println("    public " + holderType + " _value;");
          pw.println();
          pw.println("    public " + className + "() {");
          pw.println("    }");
          pw.println();
          pw.println("    public " + className + "(" + holderType + " value) {");
          pw.println("        this._value = value;");
          pw.println("    }");
          pw.println();
          pw.println("    // ?++?");
          pw.println("}");
          pw.close();
      } // writeOperation
  
  } // class JavaHolderWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java
  
  Index: JavaImplWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Binding;
  import javax.wsdl.BindingOperation;
  import javax.wsdl.Fault;
  import javax.wsdl.Input;
  import javax.wsdl.Operation;
  import javax.wsdl.Output;
  import javax.wsdl.Part;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.extensions.soap.SOAPBody;
  import javax.wsdl.extensions.soap.SOAPOperation;
  
  /**
  * This is Wsdl2java's implementation template writer.  It writes the <BindingName>Impl.java
  * file which contains the <bindingName>Impl class.
  */
  public class JavaImplWriter extends JavaWriter {
      private Binding binding;
      private SymbolTable symbolTable;
      private BindingEntry bEntry;
  
      /**
       * Constructor.
       */
      protected JavaImplWriter(
              Emitter emitter,
              BindingEntry bEntry,
              SymbolTable symbolTable) {
          super(emitter, bEntry, "Impl", "java",
                  JavaUtils.getMessage("genImpl00"));
          this.binding = bEntry.getBinding();
          this.symbolTable = symbolTable;
          this.bEntry = bEntry;
      } // ctor
  
      /**
       * Write the body of the binding's stub file.
       */
      protected void writeFileBody() throws IOException {
          PortType portType = binding.getPortType();
          PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName());
          String portTypeName = ptEntry.getName();
          pw.print("public class " + className + " implements " + portTypeName);
          pw.println(" {");
  
          List operations = binding.getBindingOperations();
          for (int i = 0; i < operations.size(); ++i) {
              BindingOperation operation = (BindingOperation) operations.get(i);
              Parameters parameters =
                      ptEntry.getParameters(operation.getOperation().getName());
              writeOperation(parameters);
          }
          pw.println("}");
          pw.close();
      } // writeFileBody
  
      private void writeOperation(Parameters parms) throws IOException {
          pw.println(parms.signature + " {");
  
          // Fill in any out parameter holders
          Iterator iparam = parms.list.iterator();
          while (iparam.hasNext()) {
              Parameter param = (Parameter) iparam.next();
              String paramType = param.type.getName();
  
              if (param.mode == Parameter.OUT) {
                  pw.print("        " + Utils.xmlNameToJava(param.name)
                          + "._value = ");
                  if ( isPrimitiveType(param.type) ) {
                      if ( "boolean".equals(paramType) ) {
                          pw.print("false");
                      } else if ("byte".equals(paramType)) {
                          pw.print("(byte)-3");
                      } else if ("short".equals(paramType)) {
                          pw.print("(short)-3");
                      } else {
                          pw.print("-3");
                      }
                  } else if (paramType.equals("java.math.BigDecimal")) {
                      pw.print("new java.math.BigDecimal(-3)");
                  } else if (paramType.equals("java.math.BigInteger")) {
                      pw.print("new java.math.BigInteger(\"-3\")");
                  } else if (paramType.equals("byte[]")) {
                      pw.print("new byte[0]");
                  } else {
                      pw.print("new " + paramType + "()");
                  }
                  pw.println(";");
              }
          }
  
          // Print the return statement
          if (parms.returnType != null) {
              pw.print("        return ");
  
              if (isPrimitiveType(parms.returnType)) {
                  String returnType = parms.returnType.getName();
                  if ("boolean".equals(returnType)) {
                      pw.println("false;");
                  } else if ("byte".equals(returnType)) {
                      pw.println("(byte)-3;");
                  } else if ("short".equals(returnType)) {
                      pw.println("short)-3;");
                  } else {
                      pw.println("-3;");
                  }
              } else {
                  pw.println("null;");
              }
          }
          pw.println("    }");
      } // writeOperation
  } // class JavaImplWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaInterfaceWriter.java
  
  Index: JavaInterfaceWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  
  import javax.wsdl.Operation;
  import javax.wsdl.PortType;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's PortType Writer.  It writes the <portTypeName>.java file
  * which contains the <portTypeName> interface.
  */
  public class JavaInterfaceWriter extends JavaWriter {
      private PortType      portType;
      private PortTypeEntry ptEntry;
      private SymbolTable   symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaInterfaceWriter(
              Emitter emitter,
              PortTypeEntry ptEntry, SymbolTable symbolTable) {
          super(emitter, ptEntry, "", "java", JavaUtils.getMessage("genIface00"));
          this.ptEntry = ptEntry;
          this.portType = ptEntry.getPortType();
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the body of the portType interface file.
       */
      protected void writeFileBody() throws IOException {
          pw.println("public interface " + className + " extends java.rmi.Remote {");
  
          // Remove Duplicates - happens with only a few WSDL's. No idea why!!! 
          // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) 
          // TODO: Remove this patch...
          // NOTE from RJB:  this is a WSDL4J bug and the WSDL4J guys have been notified.
          Iterator operations = (new HashSet(portType.getOperations())).iterator();
          while(operations.hasNext()) {
              Operation operation = (Operation) operations.next();
              writeOperation(operation);
          }
  
          pw.println("}");
          pw.close();
      } // writeFileBody
  
      /**
       * This method generates the interface signatures for the given operation.
       */
      private void writeOperation(Operation operation) throws IOException {
          writeComment(pw, operation.getDocumentationElement());
          Parameters parms = ptEntry.getParameters(operation.getName());
          pw.println(parms.signature + ";");
      } // writeOperation
  
  } // class JavaInterfaceWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaPortTypeWriter.java
  
  Index: JavaPortTypeWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  /**
  * This is Wsdl2java's PortType Writer.  It writes the <portTypeName>.java file
  * which contains the <portTypeName> interface and, when appropriate, the
  * <portTypeName>AXIS.java file which contains the server-side interface.
  */
  public class JavaPortTypeWriter implements Writer {
      private Writer interfaceWriter = null;
  
      /**
       * Constructor.
       */
      public JavaPortTypeWriter(
              Emitter emitter,
              PortType portType, SymbolTable symbolTable) {
          PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName());
  
          // Only write the portType files if the portType is referenced.
          if (ptEntry.isReferenced()) {
              interfaceWriter =
                new JavaInterfaceWriter(emitter, ptEntry, symbolTable);
          }
      } // ctor
  
      /**
       * Write all the portType bindings:  <portTypeName>.java, <portTypeName>AXIS.java.
       */
      public void write() throws IOException {
          if (interfaceWriter != null) {
              interfaceWriter.write();
          }
      } // write
  } // class JavaPortTypeWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
  
  Index: JavaServiceImplWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  import java.util.Iterator;
  import java.util.List;
  import java.util.ListIterator;
  import java.util.Map;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Port;
  import javax.wsdl.Service;
  
  import javax.wsdl.extensions.soap.SOAPAddress;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's service writer.  It writes the <serviceName>.java file.
  */
  public class JavaServiceImplWriter extends JavaWriter {
      private Service service;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaServiceImplWriter(
              Emitter emitter,
              ServiceEntry sEntry,
              SymbolTable symbolTable) {
          super(emitter, sEntry, "", "java",
                  JavaUtils.getMessage("genService00"));
          this.service = sEntry.getService();
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the body of the service file.
       */
      protected void writeFileBody() throws IOException {
          // declare class
          pw.println("public class " + className + " {");
  
          // output comments
          writeComment(pw, service.getDocumentationElement());
  
          // get ports
          Map portMap = service.getPorts();
          Iterator portIterator = portMap.values().iterator();
  
          // write a get method for each of the ports with a SOAP binding
          while (portIterator.hasNext()) {
              Port p = (Port) portIterator.next();
              Binding binding = p.getBinding();
              if (binding == null) {
                  throw new IOException(JavaUtils.getMessage("emitFailNoBinding01",
                          new String[] {p.getName()}));
              }
              
              BindingEntry bEntry =
                      symbolTable.getBindingEntry(binding.getQName());
              if (bEntry == null) {
                  throw new IOException(JavaUtils.getMessage("emitFailNoBindingEntry01",
                          new String[] {binding.getQName().toString()}));
              }
  
              PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(
                      binding.getPortType().getQName());
              if (ptEntry == null) {
                  throw new IOException(JavaUtils.getMessage("emitFailNoPortType01",
                          new String[] {binding.getPortType().getQName().toString()}));
              }
  
              // If this isn't an SOAP binding, skip it
              if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                  continue;
              }
  
              String portName = Utils.xmlNameToJavaClass(p.getName());
              String stubClass = bEntry.getName() + "Stub";
              String bindingType = ptEntry.getName();
  
              // Get endpoint address and validate it
              String address = getAddressFromPort(p);
              if (address == null) {
                  // now what?
                  throw new IOException(JavaUtils.getMessage("emitFail02",
                          portName, className));
              }
              try {
                  URL ep = new URL(address);
              }
              catch (MalformedURLException e) {
                  throw new IOException(JavaUtils.getMessage("emitFail03",
                          new String[] {portName, className, address}));
              }
  
              // Write out the get<PortName> methods
              pw.println();
              pw.println("    // " + JavaUtils.getMessage("getProxy00", portName));
              writeComment(pw, p.getDocumentationElement());
              pw.println("    private final java.lang.String " + portName + "_address = \"" + address + "\";");
  
  
              pw.println("" );
              pw.println("    public String get" + portName + "Address() {" );
              pw.println("        return " + portName + "_address;" );
              pw.println("    }" );
              pw.println("" );
  
              pw.println("    public " + bindingType + " get" + portName + "() {");
              pw.println("       java.net.URL endpoint;");
              pw.println("        try {");
              pw.println("            endpoint = new java.net.URL(" + portName + "_address);");
              pw.println("        }");
              pw.println("        catch (java.net.MalformedURLException e) {");
              pw.println("            return null; // " +
                      JavaUtils.getMessage("unlikely00"));
              pw.println("        }");
              pw.println("        return get" + portName + "(endpoint);");
              pw.println("    }");
              pw.println();
              pw.println("    public " + bindingType + " get" + portName + "(java.net.URL portAddress) {");
              pw.println("        try {");
              pw.println("            return new " + stubClass + "(portAddress);");
              pw.println("        }");
              pw.println("        catch (org.apache.axis.AxisFault e) {");
              pw.println("            return null; // ???");
              pw.println("        }");
              pw.println("    }");
          }
          // all done
          pw.println("}");
          pw.close();
      } // writeFileBody
  
      /**
       * Return the endpoint address from a <soap:address location="..."> tag
       */
      private String getAddressFromPort(Port p) {
          // Get the endpoint for a port
          List extensibilityList = p.getExtensibilityElements();
          for (ListIterator li = extensibilityList.listIterator(); li.hasNext();) {
              Object obj = li.next();
              if (obj instanceof SOAPAddress) {
                  return ((SOAPAddress) obj).getLocationURI();
              }
          }
          // didn't find it
          return null;
      } // getAddressFromPort
  
  } // class JavaServiceImplWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceWriter.java
  
  Index: JavaServiceWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  /**
  * This is Wsdl2java's Service Writer.  It writes the following files, as appropriate:
  * <serviceName>.java, <serviceName>TestCase.java.
  */
  public class JavaServiceWriter implements Writer {
      Writer serviceWriter = null;
      Writer testCaseWriter = null;
  
      /**
       * Constructor.
       */
      public JavaServiceWriter(
              Emitter emitter,
              Service service,
              SymbolTable symbolTable) {
          ServiceEntry sEntry = symbolTable.getServiceEntry(service.getQName());
          if (sEntry.isReferenced()) {
              serviceWriter =
                      new JavaServiceImplWriter(emitter, sEntry, symbolTable);
              if (emitter.bEmitTestCase) {
                  testCaseWriter =
                          new JavaTestCaseWriter(emitter, sEntry, symbolTable);
              }
          }
      } // ctor
  
      /**
       * Write all the service bindnigs:  service and testcase.
       */
      public void write() throws IOException {
          if (serviceWriter != null) {
              serviceWriter.write();
          }
          if (testCaseWriter != null) {
              testCaseWriter.write();
          }
      } // write
  
  } // class JavaServiceWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
  
  Index: JavaSkelWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  
  import javax.wsdl.Binding;
  import javax.wsdl.BindingOperation;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  import javax.wsdl.extensions.soap.SOAPBody;
  import javax.wsdl.extensions.soap.SOAPOperation;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's skeleton writer.  It writes the <BindingName>Skeleton.java
  * file which contains the <bindingName>Skeleton class.
  */
  public class JavaSkelWriter extends JavaWriter {
      private BindingEntry bEntry;
      private Binding binding;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaSkelWriter(
              Emitter emitter,
              BindingEntry bEntry,
              SymbolTable symbolTable) {
          super(emitter, bEntry, "Skeleton", "java",
                  JavaUtils.getMessage("genSkel00"));
          this.bEntry = bEntry;
          this.binding = bEntry.getBinding();
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the body of the binding's stub file.
       */
      protected void writeFileBody() throws IOException {
          PortType portType = binding.getPortType();
          PortTypeEntry ptEntry =
                  symbolTable.getPortTypeEntry(portType.getQName());
          String portTypeName = ptEntry.getName();
          boolean isRPC = true;
          if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
              isRPC = false;
          }
  
          String implType = portTypeName + " impl";
          pw.println("public class " + className + " {");
          pw.println("    private " + implType + ";");
          pw.println();
              // RJB WARNING! - is this OK?
          pw.println("    public " + className + "() {");
          pw.println("        this.impl = new " + bEntry.getName() + "Impl();");
          pw.println("    }");
          pw.println();
          pw.println("    public " + className + "(" + implType + ") {");
          pw.println("        this.impl = impl;");
          pw.println("    }");
          pw.println();
  
          List operations = binding.getBindingOperations();
          for (int i = 0; i < operations.size(); ++i) {
              BindingOperation operation = (BindingOperation) operations.get(i);
              Parameters parameters =
                      ptEntry.getParameters(operation.getOperation().getName());
  
              // Get the soapAction from the <soap:operation>
              String soapAction = "";
              Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator();
              for (; operationExtensibilityIterator.hasNext();) {
                  Object obj = operationExtensibilityIterator.next();
                  if (obj instanceof SOAPOperation) {
                      soapAction = ((SOAPOperation) obj).getSoapActionURI();
                      break;
                  }
              }
              // Get the namespace for the operation from the <soap:body>
              String namespace = "";
              Iterator bindingInputIterator
                      = operation.getBindingInput().getExtensibilityElements().iterator();
              for (; bindingInputIterator.hasNext();) {
                  Object obj = bindingInputIterator.next();
                  if (obj instanceof SOAPBody) {
                      namespace = ((SOAPBody) obj).getNamespaceURI();
                      if (namespace == null)
                          namespace = "";
                      break;
                  }
              }
              writeOperation(operation, parameters, soapAction, namespace, isRPC);
          }
          pw.println("}");
          pw.close();
      } // writeFileBody
  
      /**
       * Write the skeleton code for the given operation.
       */
      private void writeOperation(
              BindingOperation operation,
              Parameters parms,
              String soapAction,
              String namespace,
              boolean isRPC) throws IOException {
          writeComment(pw, operation.getDocumentationElement());
  
          pw.println(parms.skelSignature);
          pw.println("    {");
  
          // Instantiate the holders
          for (int i = 0; i < parms.list.size(); ++i) {
              Parameter p = (Parameter) parms.list.get(i);
  
              String holder = Utils.holder(p.type);
              if (p.mode == Parameter.INOUT) {
                  pw.println("        " + holder + " " + p.name + "Holder = new " + holder + "(" + Utils.xmlNameToJava(p.name) + ");");
              }
              else if (p.mode == Parameter.OUT) {
                  pw.println("        " + holder + " " + p.name + "Holder = new " + holder + "();");
              }
          }
  
          // Call the real implementation
          if ( parms.returnType == null )
              pw.print("        ");
          else
              pw.print("        Object ret = ");
          String call = "impl." + Utils.xmlNameToJava(operation.getName()) + "(";
          boolean needComma = false;
          for (int i = 0; i < parms.list.size(); ++i) {
              if (needComma)
                  call = call + ", ";
              else
                  needComma = true;
              Parameter p = (Parameter) parms.list.get(i);
  
              if (p.mode == Parameter.IN)
                  call = call + Utils.xmlNameToJava(p.name);
              else
                  call = call + p.name + "Holder";
          }
          call = call + ")";
          if (parms.outputs == 0)
              pw.println(call + ";");
          else
              pw.println(wrapPrimitiveType(parms.returnType, call) + ";");
  
          // Handle the outputs, if there are any.
          if (parms.inouts + parms.outputs > 0) {
              if (parms.inouts == 0 && parms.outputs == 1)
              // The only output is a single return value; simply pass it through.
                  pw.println("        return ret;");
              else if (parms.outputs == 0 && parms.inouts == 1) {
                  // There is only one inout parameter.  Find it in the parms list and write
                  // its return
                  int i = 0;
                  Parameter p = (Parameter) parms.list.get(i);
                  while (p.mode != Parameter.INOUT)
                      p = (Parameter) parms.list.get(++i);
                  pw.println("        return " + wrapPrimitiveType(p.type, p.name + "Holder._value") + ";");
              }
              else {
                  // There are more than 1 output parts, so create a Vector to put them into.
                  pw.println("        org.apache.axis.server.ParamList list = new org.apache.axis.server.ParamList();");
                  if (parms.returnType != null)
                      pw.println("        list.add(new org.apache.axis.message.RPCParam(\"" + parms.returnName + "\", ret));");
                  for (int i = 0; i < parms.list.size(); ++i) {
                      Parameter p = (Parameter) parms.list.get(i);
  
                      if (p.mode != Parameter.IN)
                          pw.println("        list.add(new org.apache.axis.message.RPCParam(\"" + p.name + "\", " + wrapPrimitiveType(p.type, p.name + "Holder._value") +"));");
                  }
                  pw.println("        return list;");
              }
          }
  
          pw.println("    }");
          pw.println();
      } // writeSkeletonOperation
  
  
  } // class JavaSkelWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Binding;
  import javax.wsdl.BindingOperation;
  import javax.wsdl.Fault;
  import javax.wsdl.Input;
  import javax.wsdl.Operation;
  import javax.wsdl.Output;
  import javax.wsdl.Part;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.extensions.soap.SOAPBody;
  import javax.wsdl.extensions.soap.SOAPOperation;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's stub writer.  It writes the <BindingName>Stub.java
  * file which contains the <bindingName>Stub class.
  */
  public class JavaStubWriter extends JavaWriter {
      private BindingEntry bEntry;
      private Binding binding;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaStubWriter(
              Emitter emitter,
              BindingEntry bEntry,
              SymbolTable symbolTable) {
          super(emitter, bEntry, "Stub", "java",
                  JavaUtils.getMessage("genStub00"));
          this.bEntry = bEntry;
          this.binding = bEntry.getBinding();
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the body of the binding's stub file.
       */
      protected void writeFileBody() throws IOException {
          PortType portType = binding.getPortType();
          PortTypeEntry ptEntry =
                  symbolTable.getPortTypeEntry(portType.getQName());
          String name = Utils.xmlNameToJavaClass(qname.getLocalPart());
          String portTypeName = ptEntry.getName();
          boolean isRPC = true;
          if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
              isRPC = false;
          }
  
          pw.println("public class " + className + " extends javax.xml.rpc.Stub implements " + portTypeName + " {");
          pw.println("    private org.apache.axis.client.Service service = null ;");
          pw.println("    private org.apache.axis.client.Call call = null ;");
          pw.println("    private java.util.Hashtable properties = new java.util.Hashtable();");
          pw.println();
          pw.println("    public " + className + "(java.net.URL endpointURL) throws org.apache.axis.AxisFault {");
          pw.println("         this();");
          pw.println("         call.setTargetEndpointAddress( endpointURL );");
          pw.println("         call.setProperty(org.apache.axis.transport.http.HTTPTransport.URL, endpointURL.toString());");
          pw.println("    }");
  
          pw.println("    public " + className + "() throws org.apache.axis.AxisFault {");
  
          HashSet types = getTypesInPortType(portType);
          Iterator it = types.iterator();
  
          pw.println("        try {" );
          pw.println("            service = new org.apache.axis.client.Service();");
          pw.println("            call = (org.apache.axis.client.Call) service.createCall();");
  
          while (it.hasNext()) {
              writeSerializationInit((Type) it.next());
          }
  
          pw.println("        }");
          pw.println("        catch(Exception t) {");
          pw.println("            throw org.apache.axis.AxisFault.makeFault(t);");
          pw.println("        }");
  
          pw.println("    }");
          pw.println();
          pw.println("    public void _setProperty(String name, Object value) {");
          pw.println("        properties.put(name, value);");
          pw.println("    }");
          pw.println();
          pw.println("    // " +
                  JavaUtils.getMessage("from00", "javax.xml.rpc.Stub"));
          pw.println("    public Object _getProperty(String name) {");
          pw.println("        return properties.get(name);");
          pw.println("    }");
          pw.println();
          pw.println("    // " +
                  JavaUtils.getMessage("from00", "javax.xml.rpc.Stub"));
          pw.println("    public void _setTargetEndpoint(java.net.URL address) {");
          pw.println("        call.setProperty(org.apache.axis.transport.http.HTTPTransport.URL, address.toString());");
          pw.println("    }");
          pw.println();
          pw.println("    // " +
                  JavaUtils.getMessage("from00", "javax.xml.rpc.Stub"));
          pw.println("    public java.net.URL _getTargetEndpoint() {");
          pw.println("        try {");
          pw.println("            return new java.net.URL((String) call.getProperty(org.apache.axis.transport.http.HTTPTransport.URL));");
          pw.println("        }");
          pw.println("        catch (java.net.MalformedURLException mue) {");
          pw.println("            return null; // ???");
          pw.println("        }");
          pw.println("    }");
          pw.println();
          pw.println("    // " +
                  JavaUtils.getMessage("from00", "javax.xml.rpc.Stub"));
          pw.println("    public synchronized void setMaintainSession(boolean session) {");
          pw.println("        call.setMaintainSession(session);");
          pw.println("    }");
          pw.println();
          pw.println("    // From javax.naming.Referenceable");
          pw.println("    public javax.naming.Reference getReference() {");
          pw.println("        return null; // ???");
          pw.println("    }");
          pw.println();
  
          List operations = binding.getBindingOperations();
          for (int i = 0; i < operations.size(); ++i) {
              BindingOperation operation = (BindingOperation) operations.get(i);
              Parameters parameters =
                      ptEntry.getParameters(operation.getOperation().getName());
  
              // Get the soapAction from the <soap:operation>
              String soapAction = "";
              Iterator operationExtensibilityIterator = operation.getExtensibilityElements().iterator();
              for (; operationExtensibilityIterator.hasNext();) {
                  Object obj = operationExtensibilityIterator.next();
                  if (obj instanceof SOAPOperation) {
                      soapAction = ((SOAPOperation) obj).getSoapActionURI();
                      break;
                  }
              }
              // Get the namespace for the operation from the <soap:body>
              String namespace = "";
              Iterator bindingInputIterator
                      = operation.getBindingInput().getExtensibilityElements().iterator();
              for (; bindingInputIterator.hasNext();) {
                  Object obj = bindingInputIterator.next();
                  if (obj instanceof SOAPBody) {
                      namespace = ((SOAPBody) obj).getNamespaceURI();
                      if (namespace == null)
                          namespace = "";
                      break;
                  }
              }
              writeOperation(operation, parameters, soapAction, namespace, isRPC);
          }
          pw.println("}");
          pw.close();
      } // writeFileBody
  
      /**
       * This method returns a set of all the Types in a given PortType.
       * The elements of the returned HashSet are Types.
       */
      private HashSet getTypesInPortType(PortType portType) {
          HashSet types = new HashSet();
          HashSet firstPassTypes = new HashSet();
  
          // Get all the types from all the operations
          List operations = portType.getOperations();
  
          for (int i = 0; i < operations.size(); ++i) {
              firstPassTypes.addAll(getTypesInOperation((Operation) operations.get(i)));
          }
  
          // Extract those types which are complex types.
          Iterator i = firstPassTypes.iterator();
          while (i.hasNext()) {
              Type type = (Type) i.next();
              if (!types.contains(type)) {
                  types.add(type);
                  if (type.isDefined() && type.getBaseType() == null) {
                      types.addAll(
                              Utils.getNestedTypes(type.getNode(), symbolTable));
                  }
              }
          }
          return types;
      } // getTypesInPortType
  
      /**
       * This method returns a set of all the Types in a given Operation.
       * The elements of the returned HashSet are Types.
       */
      private HashSet getTypesInOperation(Operation operation) {
          HashSet types = new HashSet();
          Vector v = new Vector();
  
          // Collect all the input types
          Input input = operation.getInput();
  
          if (input != null) {
              partTypes(v,
                      input.getMessage().getOrderedParts(null),
                      (bEntry.getInputBodyType(operation) == BindingEntry.USE_LITERAL));
          }
  
          // Collect all the output types
          Output output = operation.getOutput();
  
          if (output != null) {
              partTypes(v,
                      output.getMessage().getOrderedParts(null),
                      (bEntry.getOutputBodyType(operation) == BindingEntry.USE_LITERAL));
          }
  
          // Collect all the types in faults
          Map faults = operation.getFaults();
  
          if (faults != null) {
              Iterator i = faults.values().iterator();
  
              while (i.hasNext()) {
                  Fault f = (Fault) i.next();
                  partTypes(v,
                          f.getMessage().getOrderedParts(null),
                          (bEntry.getFaultBodyType(operation, f.getName()) == BindingEntry.USE_LITERAL));
              }
          }
  
          // Put all these types into a set.  This operation eliminates all duplicates.
          for (int i = 0; i < v.size(); i++)
              types.add(v.get(i));
          return types;
      } // getTypesInOperation
  
      /**
       * This method returns a vector of Types for the parts.
       */
      private void partTypes(Vector v, Collection parts, boolean literal) {
          Iterator i = parts.iterator();
  
          while (i.hasNext()) {
              Part part = (Part) i.next();
  
              QName qType;
              if (literal) {
                  qType = part.getElementName();
                  if (qType != null) {
                      v.add(symbolTable.getElementTypeEntry(qType));
                  }
              } else {
                  qType = part.getTypeName(); 
                  if (qType == null) {
                      qType = part.getElementName();
                      if (qType != null) {
                          v.add(symbolTable.getElementTypeEntry(qType));
                      }
                  }
                  else {
                      if (qType != null) {
                          v.add(symbolTable.getTypeEntry(qType));
                      }
                  }
              }
          }
      } // partTypes
  
      /**
       * In the stub constructor, write the serializer code for the complex types.
       */
      private boolean firstSer = true ;
  
      private void writeSerializationInit(Type type) throws IOException {
          if (type.getBaseType() != null || !type.getShouldEmit()) {
              return;
          }
          if ( firstSer ) {
              pw.println("            javax.xml.rpc.namespace.QName qn;" );
              pw.println("            Class cls;" );
          }
          firstSer = false ;
  
          QName qname = type.getQName();
          pw.println("            qn = new javax.xml.rpc.namespace.QName(\"" + qname.getNamespaceURI() + "\", \"" + qname.getLocalPart() + "\");");
          pw.println("            cls = " + type.getJavaName() + ".class;");
          pw.println("            call.addSerializer(cls, qn, new org.apache.axis.encoding.BeanSerializer(cls));");
          pw.println("            call.addDeserializerFactory(qn, cls, org.apache.axis.encoding.BeanSerializer.getFactory());");
          pw.println();
      } // writeSerializationInit
  
      /**
       * Write the stub code for the given operation.
       */
      private void writeOperation(
              BindingOperation operation,
              Parameters parms,
              String soapAction,
              String namespace,
              boolean isRPC) throws IOException {
  
          writeComment(pw, operation.getDocumentationElement());
  
          pw.println(parms.signature + "{");
          pw.println("        if (call.getProperty(org.apache.axis.transport.http.HTTPTransport.URL) == null) {");
          pw.println("            throw new org.apache.axis.NoEndPointException();");
          pw.println("        }");
          pw.println("        call.removeAllParameters();");
  
          // DUG: need to set the isRPC flag in the Call object
  
          // loop over paramters and set up in/out params
          for (int i = 0; i < parms.list.size(); ++i) {
              Parameter p = (Parameter) parms.list.get(i);
  
  
              QName qn = p.type.getQName();
              String typeString = "new org.apache.axis.encoding.XMLType( new javax.xml.rpc.namespace.QName(\"" + qn.getNamespaceURI() + "\", \"" +
                      qn.getLocalPart() + "\"))";
              if (p.mode == Parameter.IN) {
                  pw.println("        call.addParameter(\"" + p.name + "\", " + typeString + ", org.apache.axis.client.Call.PARAM_MODE_IN);");
              }
              else if (p.mode == Parameter.INOUT) {
                  pw.println("        call.addParameter(\"" + p.name + "\", " + typeString + ", call.PARAM_MODE_INOUT);");
              }
              else { // p.mode == Parameter.OUT
                  pw.println("        call.addParameter(\"" + p.name + "\", " + typeString + ", call.PARAM_MODE_OUT);");
              }
          }
          // set output type
          if (parms.returnType != null) {
              QName qn = parms.returnType.getQName();
              String outputType = "new org.apache.axis.encoding.XMLType(new javax.xml.rpc.namespace.QName(\"" + qn.getNamespaceURI() + "\", \"" +
                  qn.getLocalPart() + "\"))";
              pw.println("        call.setReturnType(" + outputType + ");");
  
              pw.println();
          }
  
          pw.println("        call.setProperty(org.apache.axis.transport.http.HTTPTransport.ACTION, \"" + soapAction + "\");");
          pw.println("        call.setProperty(call.NAMESPACE, \"" + namespace
                                                   + "\");" );
          pw.println("        call.setOperationName( \"" + operation.getName() + "\");" );
          pw.print("        Object resp = call.invoke(");
          pw.print("new Object[] {");
  
          // Write the input and inout parameter list
          boolean needComma = false;
          for (int i = 0; i < parms.list.size(); ++i) {
              Parameter p = (Parameter) parms.list.get(i);
  
              if (needComma) {
                  if (p.mode != Parameter.OUT)
                      pw.print(", ");
              }
              else
                  needComma = true;
              String javifiedName = Utils.xmlNameToJava(p.name);
              if (p.mode == Parameter.IN)
                  pw.print(wrapPrimitiveType(p.type, javifiedName));
              else if (p.mode == Parameter.INOUT)
                  pw.print(wrapPrimitiveType(p.type, javifiedName + "._value"));
          }
          pw.println("});");
          pw.println();
          pw.println("        if (resp instanceof java.rmi.RemoteException) {");
          pw.println("            throw (java.rmi.RemoteException)resp;");
          pw.println("        }");
  
          int allOuts = parms.outputs + parms.inouts;
          if (allOuts > 0) {
              pw.println("        else {");
              if (allOuts == 1) {
                  if (parms.inouts == 1) {
                      // There is only one output and it is an inout, so the resp object
                      // must go into the inout holder.
                      int i = 0;
                      Parameter p = (Parameter) parms.list.get(i);
  
                      while (p.mode != Parameter.INOUT) {
                          p = (Parameter) parms.list.get(++i);
                      }
                      pw.println ("            " + Utils.xmlNameToJava(p.name) + "._value = " + getResponseString(p.type, "resp"));
                  }
                  else {
                      // (parms.outputs == 1)
                      // There is only one output and it is the return value.
                      
                      // Quick Fix By scheu for now.  This should be fixed elsewhere. 
                      if (parms.returnType != null &&
                          parms.returnType.getJavaName() != null &&
                          parms.returnType.getJavaName().indexOf("[]") > 0) {
                          pw.println("             // REVISIT THIS!");
                          pw.println("             return ("+parms.returnType.getJavaName() + ")" 
                                     +"org.apache.axis.utils.JavaUtils.convert(resp,"
                                     + parms.returnType.getJavaName()+".class);");
                      } else {
                          pw.println("             return " + getResponseString(parms.returnType, "resp"));
                      }
                  }
              }
              else {
                  // There is more than 1 output.  resp is the first one.  The rest are from
                  // call.getOutputParams ().  Pull the Objects from the appropriate place -
                  // resp or call.getOutputParms - and put them in the appropriate place,
                  // either in a holder or as the return value.
                  pw.println("            java.util.Vector output = call.getOutputParams();");
                  int outdex = 0;
                  boolean firstInoutIsResp = (parms.outputs == 0);
                  for (int i = 0; i < parms.list.size (); ++i) {
                      Parameter p = (Parameter) parms.list.get (i);
                      String javifiedName = Utils.xmlNameToJava(p.name);
                      if (p.mode != Parameter.IN) {
                          if (firstInoutIsResp) {
                              firstInoutIsResp = false;
                              pw.println ("            " + javifiedName
                                      + "._value = "
                                      + getResponseString(p.type,  "resp"));
                          }
                          else {
                              pw.println ("            " + javifiedName
                                      + "._value = " + getResponseString(p.type,
                                      "((org.apache.axis.message.RPCParam) output.get("
                                      + outdex++ + ")).getValue()"));
                          }
                      }
  
                  }
                  if (parms.outputs > 0) {
                      // Quick Fix By scheu for now.  This should be fixed elsewhere.
                      if (parms.returnType != null &&
                          parms.returnType.getJavaName() != null &&
                          parms.returnType.getJavaName().indexOf("[]") > 0) {
                          pw.println("             // REVISIT THIS!");
                          pw.println("             return ("+parms.returnType.getJavaName() + ")" 
                                     +"org.apache.axis.utils.JavaUtils.convert(resp,"
                                     + parms.returnType.getJavaName()+".class);");
                      } else {
                          pw.println("             return " + getResponseString(parms.returnType, "resp"));
                      }
  
                  }
  
              }
              pw.println("        }");
          }
          pw.println("    }");
          pw.println();
      } // writeOperation
  
  } // class JavaStubWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java
  
  Index: JavaTestCaseWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Fault;
  import javax.wsdl.Operation;
  import javax.wsdl.Port;
  import javax.wsdl.PortType;
  import javax.wsdl.Service;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's TestCase writer.  It writes the <serviceName>TestCase.java file.
  */
  public class JavaTestCaseWriter extends JavaWriter {
      private Service service;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaTestCaseWriter(
              Emitter emitter,
              ServiceEntry sEntry,
              SymbolTable symbolTable) {
          super(emitter, sEntry, "TestCase", "java",
                  JavaUtils.getMessage("genTest00"));
          this.service = sEntry.getService();
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Write the common header plus the ctors.
       */
      protected void writeFileHeader() throws IOException {
          super.writeFileHeader();
  
          pw.print("public class ");
          pw.print(this.className);
          pw.println(" extends junit.framework.TestCase {");
  
          pw.print("    public ");
          pw.print(this.className);
          pw.println("(String name) {");
          pw.println("        super(name);");
          pw.println("    }");
      } // writeFileHeader
  
      /**
       * Write the body of the TestCase file.
       */
      protected void writeFileBody() throws IOException {
          // get ports
          Map portMap = service.getPorts();
          Iterator portIterator = portMap.values().iterator();
  
          while (portIterator.hasNext()) {
              Port p = (Port) portIterator.next();
              Binding binding = p.getBinding();
              BindingEntry bEntry =
                      symbolTable.getBindingEntry(binding.getQName());
  
              // If this isn't an SOAP binding, skip it
              if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                  continue;
              }
  
              String portName = Utils.xmlNameToJavaClass(p.getName());
  
              writeComment(pw, p.getDocumentationElement());
              writeServiceTestCode(portName, binding);
          }
          finish();
      } // writeFileBody
  
      public final void finish() {
          pw.println("}");
          pw.println();
          pw.flush();
          pw.close();
      } // finish
  
      public final void writeServiceTestCode(String portName, Binding binding) throws IOException {
          PortType portType = binding.getPortType();
          PortTypeEntry ptEntry =
                  symbolTable.getPortTypeEntry(portType.getQName());
          BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
          String bindingType = ptEntry.getName();
  
          pw.println();
          pw.println("    public void test" + portName + "() {");
          pw.print("        ");
          pw.print(bindingType);
          pw.print(" binding = new ");
          pw.print(this.className.substring(0, this.className.length() - "TestCase".length()));
          pw.print("().get");
          pw.print(portName);
          pw.println("();");
  
          pw.println("        assertTrue(\"" +
                  JavaUtils.getMessage("null00", "binding") +
                  "\", binding != null);");
  
          this.writePortTestCode(portType);
  
          pw.println("    }");
      } // writeServiceTestCode
  
      private final void writePortTestCode(PortType port) throws IOException {
          PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(port.getQName());
          Iterator ops = port.getOperations().iterator();
          while (ops.hasNext()) {
              pw.println("        try {");
              Operation op = (Operation) ops.next();
              String namespace = (String) emitter.getNamespaces().get(port.getQName().getNamespaceURI());
              Parameters params = ptEntry.getParameters(op.getName());
  
              if (params.returnType != null) {
                  pw.print("            ");
                  pw.print(params.returnType.getName());
                  pw.print(" value = ");
  
                  if (  isPrimitiveType( params.returnType ) ) {
                      if ( "boolean".equals( params.returnType ) ) {
                          pw.println("false;");
                      } else {
                          pw.println("-3;");
                      }
                  } else {
                      pw.println("null;");
                  }
              }
  
              pw.print("            ");
  
              if (params.returnType != null) {
                  pw.print("value = ");
              }
  
              pw.print("binding.");
              pw.print(Utils.xmlNameToJava(op.getName()));
              pw.print("(");
  
              Iterator iparam = params.list.iterator();
              boolean isFirst = true;
  
              while (iparam.hasNext()) {
                  if (isFirst) {
                      isFirst = false;
                  } else {
                      pw.print(", ");
                  }
  
                  Parameter param = (Parameter) iparam.next();
                  String paramType = param.type.getName();
                  String suffix = "";
  
                  if (param.mode != Parameter.IN) {
                      pw.print("new " + Utils.holder(param.type) + "(");
                      suffix = ")";
                  }
  
                  if (param.mode != Parameter.OUT) {
                      if ( isPrimitiveType(param.type) ) {
                          if ( "boolean".equals(paramType) ) {
                              pw.print("true");
                          } else if ("byte".equals(paramType)) {
                              pw.print("(byte)0");
                          } else if ("short".equals(paramType)) {
                              pw.print("(short)0");
                          } else {
                              pw.print("0");
                          }
                      } else if (paramType.equals("java.math.BigDecimal")) {
                          pw.print("new java.math.BigDecimal(0)");
                      } else if (paramType.equals("java.math.BigInteger")) {
                          pw.print("new java.math.BigInteger(\"0\")");
                      } else if (paramType.equals("byte[]")) {
                          pw.print("new byte[0]");
                      } else {
                          pw.print("new " + paramType + "()");
                      }
                  }
                  pw.print(suffix);
              }
  
              pw.println(");");
  
  /* I'm not sure why we'd do this...
              if ( !"void".equals(params.returnType) ) {
                  pw.print("            ");
  
                  if ( this.emitter.isPrimitiveType( params.returnType ) ) {
                      if ( "boolean".equals( params.returnType ) ) {
                          pw.println("assertTrue(\"Value is still false\", value != false);");
                      } else {
                          pw.println("assertTrue(\"Value is still -3\", value != -3);");
                      }
                  } else {
                      pw.println("assertTrue(\"Value is null\", value != null);");
                  }
              }
  */
  
              pw.println("        } catch (java.rmi.RemoteException re) {");
              pw.print("            ");
              pw.println("throw new junit.framework.AssertionFailedError(\"Remote Exception caught: \" + re );");
              pw.print("        }");
              
              Map faultMap = op.getFaults();
  
              if (faultMap != null) {
                  Iterator i = faultMap.values().iterator();
                  int count = 0;
  
                  while (i.hasNext()) {
                      count++;
                      Fault f = (Fault) i.next();
                      pw.print(" catch (");
                      pw.print(Utils.getExceptionName(f));
                      pw.println(" e" + count + ") {");
                      pw.print("            ");
                      pw.println("throw new junit.framework.AssertionFailedError(\"" + f.getName() + " Exception caught: \" + e" + count + ");");
                      pw.print("        }");
                  }
              }
              pw.println();
          }
      } // writePortTestCode
  
  } // class JavaTestCasepw
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTypeWriter.java
  
  Index: JavaTypeWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Vector;
  
  import javax.wsdl.QName;
  
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's Type Writer.  It writes the following files, as appropriate:
  * <typeName>.java, <typeName>Holder.java.
  */
  public class JavaTypeWriter implements Writer {
      public static final String HOLDER_IS_NEEDED = "Holder is needed";
  
      private Writer typeWriter = null;
      private Writer holderWriter = null;
  
      /**
       * Constructor.
       */
      public JavaTypeWriter(
              Emitter emitter,
              Type type,
              SymbolTable symbolTable) {
          if (type.isReferenced()) {
  
              // Determine what sort of type this is and instantiate the appropriate Writer.
              Node node = type.getNode();
  
              // Generate the proper class for either "complex" or "enumeration" types
              Vector v = SchemaUtils.getComplexElementTypesAndNames(
                      node, symbolTable);
              if (v != null) {
                  typeWriter = new JavaComplexTypeWriter(emitter, type, v,
                      SchemaUtils.getComplexElementExtensionBase(node,symbolTable));
              }
              else {
                  v = SchemaUtils.getEnumerationBaseAndValues(node, symbolTable);
                  if (v != null) {
                      typeWriter = new JavaEnumTypeWriter(emitter, type, v);
                  }
              }
  
              // If a type class is written, and the holder is needed (ie., something uses this
              // type as an out or inout parameter), instantiate the holder writer.
              if (v != null && holderIsNeeded(type)) {
                  holderWriter = new JavaHolderWriter(emitter, type);
              }
          }
      } // ctor
  
      /**
       * Write all the service bindnigs:  service and testcase.
       */
      public void write() throws IOException {
          if (typeWriter != null)
              typeWriter.write();
          if (holderWriter != null) {
              holderWriter.write();
          }
      } // write
  
      /**
       * Does anything use this type as an inout/out parameter?  Query the Type dynamicVar
       */
      private boolean holderIsNeeded(SymTabEntry entry) {
          Boolean holderIsNeeded =
                  (Boolean) entry.getDynamicVar(HOLDER_IS_NEEDED);
          return (holderIsNeeded != null && holderIsNeeded.booleanValue());
      } // holderIsNeeded
  } // class JavaTypeWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaUndeployWriter.java
  
  Index: JavaUndeployWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Definition;
  import javax.wsdl.Port;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This is Wsdl2java's deploy Writer.  It writes the deploy.java file.
  */
  public class JavaUndeployWriter extends JavaWriter {
      private Definition definition;
      private SymbolTable symbolTable;
  
      /**
       * Constructor.
       */
      protected JavaUndeployWriter(Emitter emitter, Definition definition, SymbolTable symbolTable) {
          super(emitter,
                  new QName(definition.getTargetNamespace(), "undeploy"),
                  "",
                  "wsdd",
                  JavaUtils.getMessage("genUndeploy00"));
          this.definition = definition;
          this.symbolTable = symbolTable;
      } // ctor
  
      /**
       * Replace the default file header with the deployment doc file header.
       */
      protected void writeFileHeader() throws IOException {
          initializeDeploymentDoc("undeploy");
      } // writeFileHeader
  
      /**
       * Write the body of the deploy.xml file.
       */
      protected void writeFileBody() throws IOException {
          writeDeployServices();
          pw.println("</undeployment>");
          pw.close();
      } // writeFileBody
  
      /**
       * Write out deployment and undeployment instructions for each WSDL service
       */
      private void writeDeployServices() throws IOException {
          //deploy the ports on each service
          Map serviceMap = definition.getServices();
          for (Iterator mapIterator = serviceMap.values().iterator(); mapIterator.hasNext();) {
              Service myService = (Service) mapIterator.next();
  
              pw.println();
              pw.println("  <!-- " + JavaUtils.getMessage("wsdlService00",
                      myService.getQName().getLocalPart()) + " -->");
              pw.println();
  
              for (Iterator portIterator = myService.getPorts().values().iterator(); portIterator.hasNext();) {
                  Port myPort = (Port) portIterator.next();
                  writeDeployPort(myPort);
              }
          }
      } //writeDeployServices
  
      /**
       * Write out deployment and undeployment instructions for given WSDL port
       */
      private void writeDeployPort(Port port) throws IOException {
          Binding binding = port.getBinding();
          BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
          String serviceName = port.getName();
  
          boolean isRPC = (bEntry.getBindingStyle() == BindingEntry.STYLE_RPC);
  
          pw.println("  <service name=\"" + serviceName + "\">");
          pw.println("  </service>");
      } //writeDeployPort
  
  } // class JavaUndeployWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriter.java
  
  Index: JavaWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import java.util.HashMap;
  
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  import org.w3c.dom.Element;
  
  /**
  * All of Wsdl2java's Writer implementations do some common stuff.  All this
  * common stuff resides in this abstract base class.  All that extensions to
  * this class have to do is implement writeFileBody.
  *
  * Emitter knows about WSDL writers, one each for PortType, Binding, Service,
  * Definition, Type.  But for some of these WSDL types, Wsdl2java generates
  * multiple files.  Each of these files has a corresponding writer that extends
  * JavaWriter.  So the Java WSDL writers (JavaPortTypeWriter, JavaBindingWriter,
  * etc.) each calls a file writer (JavaStubWriter, JavaSkelWriter, etc.) for
  * each file that that WSDL generates.
  *
  * For example, when Emitter calls JavaWriterFactory for a Binding Writer, it
  * returns a JavaBindingWriter.  JavaBindingWriter, in turn, contains a
  * JavaStubWriter, JavaSkelWriter, and JavaImplWriter since a Binding may cause
  * a stub, skeleton, and impl template to be generated.
  *
  * Note that the writers that are given to Emitter by JavaWriterFactory DO NOT
  * extend JavaWriter.  They simply implement Writer and delegate the actual
  * task of writing to extensions of JavaWriter.
  */
  
  public abstract class JavaWriter implements Writer {
      protected Emitter     emitter;
      protected QName       qname;
      protected Namespaces  namespaces;
      protected String      className;
      protected String      fileName;
      protected String      packageName;
      protected PrintWriter pw;
      protected String      message;
  
      /**
       * Constructor.  Use this one to pass in a Type.  Type contains QName and java name.
       */
      protected JavaWriter(
              Emitter emitter,
              SymTabEntry entry,
              String suffix,
              String extension,
              String message) {
          this.emitter     = emitter;
          this.qname       = entry.getQName();
          this.namespaces  = emitter.getNamespaces();
          this.className   = Utils.getJavaLocalName(entry.getName())
                  + (suffix == null ? "" : suffix);
          this.fileName    = className + '.' + extension;
          this.packageName = Utils.getJavaPackageName(entry.getName());
          this.message     = message;
      } // ctor
  
  
      /**
       * Constructor.  Use Set up all the variables needed to write a file.
       */
      protected JavaWriter(
              Emitter emitter,
              QName qname,
              String suffix,
              String extension,
              String message) {
          this.emitter     = emitter;
          this.qname       = qname;
          this.namespaces  = emitter.getNamespaces();
          this.className   = qname.getLocalPart() + (suffix == null ? "" : suffix);
          this.fileName    = className + '.' + extension;
          this.packageName = namespaces.getCreate(qname.getNamespaceURI());
          this.message     = message;
      } // ctor
  
      /**
       * Create the file, write the header, write the body.
       */
      public void write() throws IOException {
          String packageDirName = namespaces.toDir(packageName);
          String path = packageDirName + fileName;
          String fqClass = packageName + "." + className;
          
          // Check for duplicates, probably the result of namespace mapping
          if (emitter.classList.contains(fqClass)) {
              throw new IOException(JavaUtils.getMessage("duplicateClass00", fqClass));
          }
          if (emitter.fileList.contains(path)) {
              throw new IOException(JavaUtils.getMessage("duplicateFile00", path));
          }
          
          emitter.fileList.add(path);
          emitter.classList.add(fqClass);
          namespaces.mkdir(packageName);
          File file = new File(packageDirName, fileName);
          if (emitter.bVerbose) {
              System.out.println(message + ":  " + file.getPath());
          }
          pw = new PrintWriter(new FileWriter(file));
          writeFileHeader();
          writeFileBody();
      } // write
  
      /**
       * Write a common header, including the package name.
       */
      protected void writeFileHeader() throws IOException {
          pw.println("/**");
          pw.println(" * " + fileName);
          pw.println(" *");
          pw.println(" * " + JavaUtils.getMessage("wsdlGenLine00"));
          pw.println(" * " + JavaUtils.getMessage("wsdlGenLine01"));
          pw.println(" */");
          pw.println();
  
          // print package declaration
          pw.println("package " + packageName + ";");
          pw.println();
      } // writeFileHeader
  
      /**
       * output documentation element as a Java comment.
       */
      protected void writeComment(PrintWriter pw, Element element) {
          // This controls how many characters per line
          final int LINE_LENGTH = 65;
  
          if (element == null)
              return;
  
          String comment = element.getFirstChild().getNodeValue();
  
          // Strip out stuff that will really mess up our comments
          comment = comment.replace('\r', ' ');
          comment = comment.replace('\n', ' ');
  
          if (comment != null) {
              int start = 0;
  
              pw.println();  // blank line
  
              // make the comment look pretty
              while (start < comment.length()) {
                  int end = start + LINE_LENGTH;
                  if (end > comment.length())
                      end = comment.length();
                  // look for next whitespace
                  while (end < comment.length() &&
                          !Character.isWhitespace(comment.charAt(end))) {
                      end++;
                  }
                  pw.println("    // " + comment.substring(start, end).trim());
                  start = end + 1;
              }
          }
      } // writeComment
  
      /**
       * A simple map of the primitive types and their holder objects
       */
      private static HashMap TYPES = new HashMap(7);
  
      static {
          TYPES.put("int", "Integer");
          TYPES.put("float", "Float");
          TYPES.put("boolean", "Boolean");
          TYPES.put("double", "Double");
          TYPES.put("byte", "Byte");
          TYPES.put("short", "Short");
          TYPES.put("long", "Long");
      }
  
      /**
       * Return a string with "var" wrapped as an Object type if needed
       */
      protected String wrapPrimitiveType(Type type, String var) {
          String objType = type == null ? null : (String) TYPES.get(type.getName());
          if (objType != null) {
              return "new " + objType + "(" + var + ")";
          }
          else {
              return var;
          }
      } // wrapPrimitiveType
  
      /**
       * Return the Object variable 'var' cast to the appropriate type
       * doing the right thing for the primitive types.
       */
      protected String getResponseString(Type type, String var) {
          if (type == null) {
              return ";";
          }
          else {
              String objType = (String) TYPES.get(type.getName());
              if (objType != null) {
                  return "((" + objType + ") " + var + ")." + type.getName() + "Value();";
              }
              else {
                  return "(" + type.getName() + ") " + var + ";";
              }
          }
      } // getResponseString
  
      protected boolean isPrimitiveType(Type type) {
          return TYPES.get(type.getName()) != null;
      }
  
      /**
       * Initialize the deployment document, spit out preamble comments
       * and opening tag.
       */
      protected void initializeDeploymentDoc(String deploymentOpName) throws IOException {
          if ("deploy".equals(deploymentOpName)) {
              pw.println(JavaUtils.getMessage("deploy00"));
          }
          else {
              pw.println(JavaUtils.getMessage("deploy01"));
          }
          pw.println(JavaUtils.getMessage("deploy02"));
          if ("deploy".equals(deploymentOpName)) {
              pw.println(JavaUtils.getMessage("deploy03"));
          }
          else {
              pw.println(JavaUtils.getMessage("deploy04"));
          }
          pw.println(JavaUtils.getMessage("deploy05"));
          pw.println(JavaUtils.getMessage("deploy06"));
          if ("deploy".equals(deploymentOpName)) {
              pw.println(JavaUtils.getMessage("deploy07"));
          }
          else {
              pw.println(JavaUtils.getMessage("deploy08"));
          }
          pw.println(JavaUtils.getMessage("deploy09"));
          pw.println();
          if ("deploy".equals(deploymentOpName)) {
              pw.println("<deployment");
              pw.println("    xmlns=\"http://xml.apache.org/axis/wsdd/\"");
              pw.println("    xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\">");
          }
          else {
              pw.println("<undeployment");
              pw.println("    xmlns=\"http://xml.apache.org/axis/wsdd/\">");
          }
      } // initializeDeploymentDoc
  
      /**
       * Does the given file already exist?
       */
      protected boolean fileExists (String name, String namespace) throws IOException
      {
          String packageName = emitter.getNamespaces().getAsDir(namespace);
          String fullName = packageName + name;
          return new File (fullName).exists();
      } // fileExists
  
      /**
       * Write the body of the file.  This is what extenders of this class must
       * implement
       */
      protected abstract void writeFileBody() throws IOException;
  
  } // abstract class JavaWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriterFactory.java
  
  Index: JavaWriterFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Definition;
  import javax.wsdl.Message;
  import javax.wsdl.Operation;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  /**
  * This is Wsdl2java's implementation of the WriterFactory.
  */
  
  public class JavaWriterFactory implements WriterFactory {
      private Emitter emitter;
  
      /**
       * Default constructor.  Note that this class is unusable until setEmitter
       * is called.
       */
      public JavaWriterFactory() {
      } // ctor
  
      /**
       * Do the Wsdl2java writer pass:
       * - resolve name clashes
       * - construct signatures
       */
      public void writerPass(Definition def, SymbolTable symbolTable) {
          javifyNames(symbolTable);
          resolveNameClashes(symbolTable);
          ignoreNonSOAPBindingPortTypes(symbolTable);
          constructSignatures(symbolTable);
          determineIfHoldersNeeded(symbolTable);
      } // writerPass
  
      /**
       * Provide the emitter object to this class.
       */
      public void setEmitter(Emitter emitter) {
          this.emitter = emitter;
      } // setEmitter
  
      /**
       * Since Wsdl2java doesn't emit anything for Messages, return the No-op writer.
       */
      public Writer getWriter(Message message, SymbolTable symbolTable) {
          return new NoopWriter();
      } // getWriter
  
      /**
       * Return Wsdl2java's JavaPortTypeWriter object.
       */
      public Writer getWriter(PortType portType, SymbolTable symbolTable) {
          return new JavaPortTypeWriter(emitter, portType, symbolTable);
      } // getWriter
  
      /**
       * Return Wsdl2java's JavaBindingWriter object.
       */
      public Writer getWriter(Binding binding, SymbolTable symbolTable) {
          return new JavaBindingWriter(emitter, binding, symbolTable);
      } // getWriter
  
      /**
       * Return Wsdl2java's JavaServiceWriter object.
       */
      public Writer getWriter(Service service, SymbolTable symbolTable) {
          return new JavaServiceWriter(emitter, service, symbolTable);
      } // getWriter
  
      /**
       * Return Wsdl2java's JavaTypeWriter object.
       */
      public Writer getWriter(Type type, SymbolTable symbolTable) {
          return new JavaTypeWriter(emitter, type, symbolTable);
      } // getWriter
  
      /**
       * Return Wsdl2java's JavaDefinitionWriter object.
       */
      public Writer getWriter(Definition definition, SymbolTable symbolTable) {
          return new JavaDefinitionWriter(emitter, definition, symbolTable);
      } // getWriter
  
      /**
       * Fill in the names of each SymTabEntry with the javaified name
       */
      private void javifyNames(SymbolTable symbolTable) {
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  SymTabEntry entry = (SymTabEntry) v.elementAt(i);
  
                  // If entry instanceof Type, then the java name has already been filled in.
                  // Don't try to do it again.  This method should really be doing the filling in
                  // of ALL enty java names, but that's another step toward generalizing the
                  // framework that I don't have time for right now.
                  if (!(entry instanceof Type)) {
                      entry.setName(symbolTable.getJavaName(entry.getQName()));
                  }
              }
          }
      } // javifyNames
  
      /**
       * Messages, PortTypes, Bindings, and Services can share the same name.  If they do in this
       * Definition, force their names to be suffixed with _PortType and _Service, respectively.
       */
      private void resolveNameClashes(SymbolTable symbolTable) {
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = new Vector((Vector) it.next());  // New vector we can temporarily add to it
              if (v.size() > 1) {
                  boolean resolve = true;
                  // Common Special Case:
                  // If a Type and ElementType have the same QName, and the ElementType
                  // uses type= to reference the Type, then they are the same class so 
                  // don't bother mangling.
                  if (v.size() == 2 &&
                      ((v.elementAt(0) instanceof ElementType &&
                        v.elementAt(1) instanceof Type) ||
                       (v.elementAt(1) instanceof ElementType &&
                        v.elementAt(0) instanceof Type))) {
                      ElementType e = null;
                      if (v.elementAt(0) instanceof ElementType) {
                          e = (ElementType)v.elementAt(0);
                      } else {
                          e = (ElementType)v.elementAt(1);
                      }
                      QName eType = Utils.getNodeTypeRefQName(e.getNode(), "type");
                      if (eType != null && eType.equals(e.getQName()))
                          resolve = false;
                  }
                  // Other Special Case:
                  // If the names are already different, no mangling is needed.
                  if (resolve) {
                      resolve = false;  // Assume false
                      String name = null;
                      for (int i = 0; i < v.size() && !resolve; ++i) {
                          SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                           if (entry instanceof MessageEntry ||
                               entry instanceof BindingEntry) {
                               ; // Don't process these
                           } else if (name== null) {
                               name = entry.getName();
                           } else if (name.equals(entry.getName())) {
                               resolve = true;  // Need to do resolution
                           } 
  
                      }
                  }
  
                      
                  // Full Mangle if resolution is necessary.
                  if (resolve) {
                      boolean firstType = true;
                      for (int i = 0; i < v.size(); ++i) {
                          SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                          if (entry instanceof ElementType) {
                              entry.setName(mangleName(entry.getName() , "_ElemType"));
                          }
                          else if (entry instanceof Type) {
                              // Search all other types for java names that match this one.
                              // The sameJavaClass method returns true if the java names are
                              // the same (ignores [] ).
                              if (firstType) {
                                  firstType = false;
                                  Vector types = symbolTable.getTypes();
                                  for (int j = 0; j < types.size(); ++j) {
                                      Type type = (Type) types.elementAt(j);
                                      if (type != entry && 
                                          !(type instanceof ElementType) &&
                                          type.getBaseType() == null &&
                                          sameJavaClass(((Type)entry).getName(), type.getName())) {
                                          v.add(type);  
                                      }
                                  }
                              }
                              entry.setName(mangleName(entry.getName() , "_Type"));
                          }
                          else if (entry instanceof PortTypeEntry) {
                              entry.setName(mangleName(entry.getName() , "_Port"));
                          }
                          else if (entry instanceof ServiceEntry) {
                              entry.setName(mangleName(entry.getName() , "_Service"));
                          }
                          // else if (entry instanceof MessageEntry) {
                          //     we don't care about messages
                          // }
                          // else if (entry instanceof BindingEntry) {
                          //     since files generated from bindings all append strings to the name,
                          //     we don't care about bindings
                          // }
                      }
                  }
              }
          }
      } // resolveNameClashes
  
      /**
       * Change the indicated type name into a mangled form using the mangle string.
       */
      private String mangleName(String name, String mangle) {
          int index = name.indexOf("[");
          if (index >= 0) {
              String pre = name.substring(0, index);
              String post = name.substring(index);
              return pre + mangle + post;
          }
          else
              return name + mangle;
      }
  
      /**
       * Returns true if same java class, ignore []                                 
       */
      private boolean sameJavaClass(String one, String two) {     
          int index1 = one.indexOf("[");
          int index2 = two.indexOf("[");
          if (index1 > 0)
              one = one.substring(0, index1);
          if (index2 > 0)
              two = two.substring(0, index2);
          return one.equals(two);
      }
  
      /**
       * If a binding's type is not TYPE_SOAP, then we don't use that binding's portType.
       */
      private void ignoreNonSOAPBindingPortTypes(SymbolTable symbolTable) {
  
          // Look at all uses of the portTypes.  If none of the portType's bindings are of type
          // TYPE_SOAP, then turn off that portType's isReferenced flag.
  
          Vector unusedPortTypes = new Vector();
          Vector usedPortTypes = new Vector();
  
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                  if (entry instanceof BindingEntry) {
                      BindingEntry bEntry = (BindingEntry) entry;
                      Binding binding = bEntry.getBinding();
                      PortType portType = binding.getPortType();
                      PortTypeEntry ptEntry =
                        symbolTable.getPortTypeEntry(portType.getQName());
  
                      if (bEntry.getBindingType() == BindingEntry.TYPE_SOAP) {
                          // If a binding is of type TYPE_SOAP, then mark its portType used
                          // (ie., add it to the usedPortTypes list.  If the portType was
                          // previously marked as unused, unmark it (in other words, remove it
                          // from the unusedPortTypes list).
                          usedPortTypes.add(ptEntry);
                          if (unusedPortTypes.contains(ptEntry)) {
                              unusedPortTypes.remove(ptEntry);
                          }
                      }
                      else {
                          // If a binding is not of type TYPE_SOAP, then mark its portType as
                          // unused ONLY if it hasn't already been marked as used.
                          if (!usedPortTypes.contains(ptEntry)) {
                              unusedPortTypes.add(ptEntry);
                          }
                      }
                  }
              }
          }
  
          // Go through all the portTypes that are marked as unused and set their isReferenced flags
          // to false.
          for (int i = 0; i < unusedPortTypes.size(); ++i) {
              PortTypeEntry ptEntry = (PortTypeEntry) unusedPortTypes.get(i);
              ptEntry.setIsReferenced(false);
          }
      } // ignoreNonSOAPBindingPortTypes
  
      private void constructSignatures(SymbolTable symbolTable) {
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                  if (entry instanceof PortTypeEntry) {
                      PortTypeEntry ptEntry = (PortTypeEntry) entry;
                      PortType portType = ptEntry.getPortType();
                      // Remove Duplicates - happens with only a few WSDL's. No idea why!!! 
                      // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) 
                      // TODO: Remove this patch...
                      // NOTE from RJB:  this is a WSDL4J bug and the WSDL4J guys have been
                      // notified.
                      Iterator operations =
                              new HashSet(portType.getOperations()).iterator();
                      while(operations.hasNext()) {
                          Operation operation = (Operation) operations.next();
                          String name = operation.getName();
                          constructSignatures(ptEntry.getParameters(name), name);
                      }
                  }
              }
          }
      } // constructSignatures
  
      /**
       * Construct the signatures.  signature is used by both the interface and the stub.
       * skelSig is used by the skeleton.
       */
      private void constructSignatures(Parameters parms, String opName) {
          String name  = Utils.xmlNameToJava(opName);
          int allOuts = parms.outputs + parms.inouts;
          String ret = parms.returnType == null ? "void" : parms.returnType.getName();
          String signature = "    public " + ret + " " + name + "(";
          String skelSig = null;
  
          if (allOuts == 0)
              skelSig = "    public void " + name + "(";
          else
              skelSig = "    public Object " + name + "(";
  
          boolean needComma = false;
  
          for (int i = 0; i < parms.list.size(); ++i) {
              Parameter p = (Parameter) parms.list.get(i);
  
              if (needComma) {
                  signature = signature + ", ";
                  if (p.mode != Parameter.OUT)
                      skelSig = skelSig + ", ";
              }
              else
                  needComma = true;
  
              String javifiedName = Utils.xmlNameToJava(p.name);
              if (p.mode == Parameter.IN) {
                  signature = signature + p.type.getName() + " " + javifiedName;
                  skelSig = skelSig + p.type.getName() + " " + javifiedName;
              }
              else if (p.mode == Parameter.INOUT) {
                  signature = signature + Utils.holder(p.type) + " " +
                          javifiedName;
                  skelSig = skelSig + p.type.getName() + " " + javifiedName;
              }
              else// (p.mode == Parameter.OUT)
              {
                  signature = signature + Utils.holder(p.type) + " " +
                          javifiedName;
              }
          }
          signature = signature + ") throws java.rmi.RemoteException";
          skelSig = skelSig + ") throws java.rmi.RemoteException";
          if (parms.faultString != null) {
              signature = signature + ", " + parms.faultString;
              skelSig = skelSig + ", " + parms.faultString;
          }
          parms.signature = signature;
          parms.skelSignature = skelSig;
      } // constructSignatures
  
      /**
       * Find all inout/out parameters and add a flag to the Type of that parameter saying a holder
       * is needed.
       */
      private void determineIfHoldersNeeded(SymbolTable symbolTable) {
          Iterator it = symbolTable.getHashMap().values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  if (v.get(i) instanceof PortTypeEntry) {
  
                          // If entry is a portTypeEntry, look at all the Parameters
                      PortTypeEntry ptEntry = (PortTypeEntry) v.get(i);
                      Iterator operations =
                        ptEntry.getParameters().values().iterator();
                      while (operations.hasNext()) {
                          Parameters parms = (Parameters) operations.next();
                          for (int j = 0; j < parms.list.size(); ++j) {
                              Parameter p =
                                      (Parameter)parms.list.get(j);
  
                              // If the given parameter is an inout or out parameter, then
                              // set a HOLDER_IS_NEEDED flag using the dynamicVar design.
                              if (p.mode != Parameter.IN) {
                                  p.type.setDynamicVar(
                                          JavaTypeWriter.HOLDER_IS_NEEDED,
                                          new Boolean(true));
                              }
                          }
                      }
                  }
              }
          }
      } // determineIfHoldersNeeded
  
  } // class JavaWriterFactory
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/MessageEntry.java
  
  Index: MessageEntry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import javax.wsdl.Message;
  import javax.wsdl.QName;
  
  /**
  * This class represents a WSDL message.  It simply encompasses the WSDL4J Message object so it can
  * reside in the SymbolTable.
  */
  public class MessageEntry extends SymTabEntry {
      private Message message;
  
      /**
       * Construct a MessageEntry from a WSDL4J Message object.
       */
      public MessageEntry(Message message) {
          super(message.getQName());
          this.message = message;
      } // ctor
  
      /**
       * Get this entry's Message object.
       */
      public Message getMessage() {
          return message;
      } // getMessage
  } // class MessageEntry
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Namespaces.java
  
  Index: Namespaces.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.File;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.StringTokenizer;
  
  import org.apache.axis.utils.JavaUtils;
  
  /**
  * This class is essentially a HashMap of <namespace, package name> pairs with
  * a few extra wizzbangs.
  */
  public class Namespaces extends HashMap {
      private String root;
      private String defaultPackage = null;
  
      /**
       * Instantiate a Namespaces object whose packages will all reside under root.
       */
      public Namespaces(String root) {
          super();
          this.root = root;
      } // ctor
  
      /**
       * Instantiate a clone of an existing Namespaces object.
       */
      private Namespaces(Namespaces clone) {
          super(clone);
          this.root = clone.root;
          this.defaultPackage = clone.defaultPackage;
      } // ctor
  
      /**
       * Instantiate a clone of this Namespaces object.
       */
      public Object clone() {
          return new Namespaces(this);
      } // clone
  
      /**
       * Get the package name for the given namespace.  If there is no entry in the HashMap for
       * this namespace, create one.
       */
      public String getCreate(String key) {
          if (defaultPackage != null) {
              return defaultPackage;
          }
          Object value = super.get(key);
          if (value == null) {
              value = Utils.makePackageName((String) key);
              put(key, value);
          }
          return (String) value;
      } // getCreate
  
      /**
       * Get the package name in directory format (dots replaced by slashes).  If the package name
       * doesn't exist in the HashMap, return "".
       */
      public String getAsDir(String key) {
          if (defaultPackage != null) {
              return toDir(defaultPackage);
          }
          String pkg = (String) get(key);
          return toDir(pkg);
      } // getAsDir
  
      /**
       * Return the given package name in directory format (dots replaced by slashes).  If pkg is null,
       * "" is returned.
       */
      public String toDir(String pkg) {
          String dir = null;
          if (pkg != null) {
              pkg = pkg.replace('.', File.separatorChar);
          }
          if (root == null) {
              dir = pkg;
          }
          else {
              dir = root + File.separatorChar + pkg;
          }
  
          return dir == null ? "" : dir + File.separatorChar;
      } // toDir
  
      /**
       * Like HashMap's putAll, this adds the given map's contents to this map.  But it
       * also makes sure the value strings are javified.
       */
      public void putAll(Map map) {
          Iterator i = map.keySet().iterator();
          while (i.hasNext()) {
              Object key = i.next();
              String pkg = (String) map.get(key);
              pkg = javify(pkg);
              put(key, pkg);
          }
      } // putAll
  
      /**
       * Make sure each package name doesn't conflict with a Java keyword.
       * Ie., org.apache.import.test becomes org.apache.import_.test.
       */
      private String javify(String pkg) {
          StringTokenizer st = new StringTokenizer(pkg, ".");
          pkg = "";
          while (st.hasMoreTokens()) {
              String token = st.nextToken();
              if (JavaUtils.isJavaKeyword(token)) {
                  token = JavaUtils.makeNonJavaKeyword(token);
              }
              pkg = pkg + token;
              if (st.hasMoreTokens()) {
                  pkg = pkg + '.';
              }
          }
          return pkg;
      } // javify
  
      /**
       * Make a directory for the given package under root.
       */
      public void mkdir(String pkg) {
          String pkgDirString = toDir(pkg);
          File packageDir = new File(pkgDirString);
          packageDir.mkdirs();
      } // mkdir
  
      /**
       * Set a package name that overrides the namespace map
       * 
       * @param a java package name (e.g. com.foo)
       */ 
      public void setDefaultPackage(String defaultPackage) {
          this.defaultPackage = defaultPackage;
      }
  
  } // class Namespaces
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/NoopWriter.java
  
  Index: NoopWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  /**
  * This writer doesn't do anything.  Wsdl2java doesn't write anything for messages, but since
  * the WriterFactory interface requires that getWriter(Message, SymbolTable) return a Writer, it
  * has to return something.  Ergo this class.
  */
  public class NoopWriter implements Writer {
  
      /**
       * Do a whole lot of nothing.
       */
      public void write() throws IOException {
      } // write
  } // class NoopWriter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.util.Vector;
  
  /**
    * This class simply collects
    */
  public class Parameter {
  
      // constant values for the parameter mode.
      public static final byte IN = 1;
      public static final byte OUT = 2;
      public static final byte INOUT = 3;
  
      public String name;
      public Type type;
      public byte mode = IN;
  
      public String toString() {
          return "(" + type + ", " + name + ", "
                  + (mode == IN ? "IN)" : mode == INOUT ? "INOUT)" : "OUT)");
      } // toString
  } // class Parameter
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Parameters.java
  
  Index: Parameters.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.util.Vector;
  
  /**
   * This class simply collects all the parameter or message data for an operation into one place.
   */
  public class Parameters {
  
      // This vector contains instances of the Parameter class
      public Vector list = new Vector();
  
      // The type of the first output part, used as the method's return value
      public Type returnType = null;
  
      // The name of the return type (from the part name of the output message.
      // Used to create the RPCParam for the return value.
      public String returnName = null;
  
      // A comma-separated list of all of the faults
      public String faultString = null;
  
      // The signature that the interface and the stub will use
      public String signature = null;
  
      // The signature that the skeleton will use
      public String skelSignature = null;
  
      // The numbers of the respective parameters
      public int inputs = 0;
      public int inouts = 0;
      public int outputs = 0;
  
      public String toString() {
          return "\nreturnType = " + returnType
                  + "\nreturnTypeName = " + returnName
                  + "\nfaultString = " + faultString
                  + "\nsignature = " + signature
                  + "\nskelSignature = " + skelSignature
                  + "\n(inputs, inouts, outputs) = (" + inputs + ", " + inouts + ", " + outputs + ")"
                  + "\nlist = " + list;
      } // toString
  } // class Parameters
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/PortTypeEntry.java
  
  Index: PortTypeEntry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import java.util.HashMap;
  
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  
  /**
  * This class represents a WSDL portType.  It encompasses the WSDL4J PortType object so it can
  * reside in the SymbolTable.  It also adds the parameter information, which is missing from the
  * WSDL4J PortType object.
  */
  public class PortTypeEntry extends SymTabEntry {
      private PortType portType;
      private HashMap  parameters = new HashMap ();
  
      /**
       * Construct a PortTypeEntry from a WSDL4J PortType object and a HashMap of Parameters objects,
       * keyed off of the operation name.
       */
      public PortTypeEntry(PortType portType, HashMap parameters) {
          super(portType.getQName());
          this.portType = portType;
          this.parameters = parameters;
      } // ctor
  
      /**
       * Get this entry's PortType object.
       */
      public PortType getPortType() {
          return portType;
      } // getPortType
  
      /**
       * Get the Parameters object for the given operation.
       */
      public Parameters getParameters(String operationName) {
          return (Parameters) parameters.get(operationName);
      } // getParameters
  
      /**
       * Get all of the parameters for all operations.
       */
      public HashMap getParameters() {
          return parameters;
      } // getParameters
  
  } // class PortTypeEntry
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/RefdType.java
  
  Index: RefdType.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  
  /**
   * This Type is for a QName found in a reference is not defined.
   * If the type is later defined, the RefdType is replaced with a new Type
   */
  public class RefdType extends Type {
      public RefdType(QName pqName, String pjName) {
          super(pqName, pjName, null);
      }
  };
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/SchemaUtils.java
  
  Index: SchemaUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  import org.w3c.dom.NamedNodeMap;
  
  import javax.wsdl.QName;
  import javax.wsdl.Fault;
  import javax.wsdl.Message;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.text.Collator;
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.Locale;
  import java.util.StringTokenizer;
  import java.util.Vector;
  
  
  /**
   * This class contains static utility methods specifically for schema type queries.
   *
   * @author Rich Scheuerle  (scheu@us.ibm.com)
   */
  public class SchemaUtils {
  
      /**
       * If the specified node represents a supported JAX-RPC complexType/element,
       * a Vector is returned which contains the child element types and
       * child element names.  The even indices are the element types (Types) and
       * the odd indices are the corresponding names (Strings).
       * If the specified node is not a supported JAX-RPC complexType/element
       * null is returned.
       */
      public static Vector getComplexElementTypesAndNames(Node node, SymbolTable symbolTable) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive into it.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
              NodeList children = node.getChildNodes();
              Node complexNode = null;
              for (int j = 0; j < children.getLength() && complexNode == null; j++) {
                  QName complexKind = Utils.getNodeQName(children.item(j));
                  if (complexKind != null &&
                      complexKind.getLocalPart().equals("complexType") &&
                      Utils.isSchemaNS(complexKind.getNamespaceURI())) {
                      complexNode = children.item(j);
                      node = complexNode;
                  }
              }
          }
  
          // Expecting a schema complexType
          nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("complexType") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Under the complexType there could be complexContent &
              // extension elements if this is a derived type.  Skip over these.
              NodeList children = node.getChildNodes();
              Node complexContent = null;
              Node extension = null;
              for (int j = 0; j < children.getLength() && complexContent == null; j++) {
                  QName complexContentKind = Utils.getNodeQName(children.item(j));
                  if (complexContentKind != null &&
                      complexContentKind.getLocalPart().equals("complexContent") &&
                      Utils.isSchemaNS(complexContentKind.getNamespaceURI()))
                      complexContent = children.item(j);
              }
              if (complexContent != null) {
                  children = complexContent.getChildNodes();
                  for (int j = 0; j < children.getLength() && extension == null; j++) {
                      QName extensionKind = Utils.getNodeQName(children.item(j));
                      if (extensionKind != null &&
                          extensionKind.getLocalPart().equals("extension") &&
                          Utils.isSchemaNS(extensionKind.getNamespaceURI()))
                          extension = children.item(j);
                  }
              }
              if (extension != null) {
                  node = extension;  // Skip over complexContent and extension
              }
  
  
              // Under the complexType (or extension) there should be a sequence or all group node.
              // (There may be other #text nodes, which we will ignore).
              children = node.getChildNodes();
              Node groupNode = null;
              for (int j = 0; j < children.getLength() && groupNode == null; j++) {
                  QName groupKind = Utils.getNodeQName(children.item(j));
                  if (groupKind != null &&
                      (groupKind.getLocalPart().equals("sequence") ||
                       groupKind.getLocalPart().equals("all")) &&
                      Utils.isSchemaNS(groupKind.getNamespaceURI()))
                      groupNode = children.item(j);
              }
  
              if (groupNode == null) {
                  return new Vector();
              }
              if (groupNode != null) {
  
                  // Process each of the element nodes under the group node
                  Vector v = new Vector();
                  NodeList elements = groupNode.getChildNodes();
                  for (int i=0; i < elements.getLength(); i++) {
                      QName elementKind = Utils.getNodeQName(elements.item(i));
                      if (elementKind != null &&
                          elementKind.getLocalPart().equals("element") &&
                          Utils.isSchemaNS(elementKind.getNamespaceURI())) {
  
                          // Get the name and type qnames.
                          // The name of the element is the local part of the name's qname.
                          // The type qname is used to locate the Type, which is then
                          // used to retrieve the proper java name of the type.
                          Node elementNode = elements.item(i);
                          QName nodeName = Utils.getNodeNameQName(elementNode);
                          QName nodeType = Utils.getNodeTypeRefQName(elementNode);
                          boolean typeAttr = false;
                          if (Utils.getNodeTypeRefQName(elementNode, "type") != null)
                              typeAttr = true;
                          if (nodeType == null) { // The element may use an anonymous type
                              nodeType = nodeName;
                              typeAttr = true;
                          }
  
                          Type Type = (Type) symbolTable.getTypeEntry(nodeType, !typeAttr);
                          if (Type != null) {
                              v.add(Type);
                              v.add(nodeName.getLocalPart());
                          }
                      }
                  }
                  return v;
              }
          }
          return null;
      }
  
      /**
       * If the specified node represents a supported JAX-RPC complexType/element
       * which extends another complexType.  The Type of the base is returned.
       */
      public static Type getComplexElementExtensionBase(Node node, SymbolTable symbolTable) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive into it.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
              NodeList children = node.getChildNodes();
              Node complexNode = null;
              for (int j = 0; j < children.getLength() && complexNode == null; j++) {
                  QName complexKind = Utils.getNodeQName(children.item(j));
                  if (complexKind != null &&
                      complexKind.getLocalPart().equals("complexType") &&
                      Utils.isSchemaNS(complexKind.getNamespaceURI())) {
                      complexNode = children.item(j);
                      node = complexNode;
                  }
              }
          }
  
          // Expecting a schema complexType
          nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("complexType") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Under the complexType there could be should be a complexContent &
              // extension elements if this is a derived type. 
              NodeList children = node.getChildNodes();
              Node complexContent = null;
              Node extension = null;
              for (int j = 0; j < children.getLength() && complexContent == null; j++) {
                  QName complexContentKind = Utils.getNodeQName(children.item(j));
                  if (complexContentKind != null &&
                      complexContentKind.getLocalPart().equals("complexContent") &&
                      Utils.isSchemaNS(complexContentKind.getNamespaceURI()))
                      complexContent = children.item(j);
              }
              if (complexContent != null) {
                  children = complexContent.getChildNodes();
                  for (int j = 0; j < children.getLength() && extension == null; j++) {
                      QName extensionKind = Utils.getNodeQName(children.item(j));
                      if (extensionKind != null &&
                          extensionKind.getLocalPart().equals("extension") &&
                          Utils.isSchemaNS(extensionKind.getNamespaceURI()))
                          extension = children.item(j);
                  }
              }
              if (extension == null) {
                  return null;  // No extension                               
              }
  
              // Get the QName of the extension base
              QName extendsType = Utils.getNodeTypeRefQName(extension, "base");
              if (extendsType == null) {
                  return null; // No extension base
              }
              // Return associated Type
              return (Type) symbolTable.getTypeEntry(extendsType);
          }
          return null;
      }
  
      /**
       * If the specified node represents a supported JAX-RPC enumeration,
       * a Vector is returned which contains the base type and the enumeration values.
       * The first element in the vector is the base type (an Type).
       * Subsequent elements are values (Strings).
       * If this is not an enumeration, null is returned.
       */
      public static Vector getEnumerationBaseAndValues(Node node, SymbolTable symbolTable) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive into it.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
              NodeList children = node.getChildNodes();
              Node simpleNode = null;
              for (int j = 0; j < children.getLength() && simpleNode == null; j++) {
                  QName simpleKind = Utils.getNodeQName(children.item(j));
                  if (simpleKind != null &&
                      simpleKind.getLocalPart().equals("simpleType") &&
                      Utils.isSchemaNS(simpleKind.getNamespaceURI())) {
                      simpleNode = children.item(j);
                      node = simpleNode;
                  }
              }
          }
          // Get the node kind, expecting a schema simpleType
          nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("simpleType") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Under the simpleType there should be a restriction.
              // (There may be other #text nodes, which we will ignore).
              NodeList children = node.getChildNodes();
              Node restrictionNode = null;
              for (int j = 0; j < children.getLength() && restrictionNode == null; j++) {
                  QName restrictionKind = Utils.getNodeQName(children.item(j));
                  if (restrictionKind != null &&
                      restrictionKind.getLocalPart().equals("restriction") &&
                      Utils.isSchemaNS(restrictionKind.getNamespaceURI()))
                      restrictionNode = children.item(j);
              }
  
              // The restriction node indicates the type being restricted
              // (the base attribute contains this type).
              // The base type must be a built-in type...and we only think
              // this makes sense for string.
              Type baseEType = null;
              if (restrictionNode != null) {
                  QName baseType = Utils.getNodeTypeRefQName(restrictionNode, "base");
                  baseEType = symbolTable.getTypeEntry(baseType);
                  if (baseEType != null && 
                      !baseEType.getJavaName().equals("java.lang.String")) {
                      baseEType = null;
                  }
              }
  
              // Process the enumeration elements underneath the restriction node
              if (baseEType != null && restrictionNode != null) {
  
                  Vector v = new Vector();
                  v.add(baseEType);
                  NodeList enums = restrictionNode.getChildNodes();
                  for (int i=0; i < enums.getLength(); i++) {
                      QName enumKind = Utils.getNodeQName(enums.item(i));
                      if (enumKind != null &&
                          enumKind.getLocalPart().equals("enumeration") &&
                          Utils.isSchemaNS(enumKind.getNamespaceURI())) {
  
                          // Put the enum value in the vector.
                          Node enumNode = enums.item(i);
                          String value = Utils.getAttribute(enumNode, "value");
                          if (value != null) {
                              v.add(value);
                          }
                      }
                  }
                  return v;
              }
          }
          return null;
      }
  
      /**
       * If the specified node represents an array encoding of one of the following
       * forms, then return the qname repesenting the element type of the array.
       */
      public static QName getArrayElementQName(Node node) {
          QName qName = getCollectionElementQName(node);
          if (qName == null)
              qName = getArrayElementQName_JAXRPC(node);
          // if (qName == null)
          //   qName = getArrayElementQName_nonJAXRPC(node);
          return qName;
      }
  
      /**
       * If the specified node represents an element that refernces a collection
       * then return the qname repesenting the element type of the collection.
       *
       *  <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/>
       *
       */
      private static QName getCollectionElementQName(Node node) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive get its type.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Get the qName of just the type.
              // The compare it against the full type of the node, which
              // takes into account maxOccurs and could return a collection type.
              // If different, return just the type (which is the collection element type).
              QName justTypeQName = Utils.getNodeTypeRefQName(node, "type");
              if (justTypeQName != null) {
                  QName fullTypeQName = Utils.getNodeTypeRefQName(node);
                  if (justTypeQName != fullTypeQName)
                      return justTypeQName;
              }
          }
          return null;
      }
  
      /**
       * If the specified node represents an array encoding of one of the following
       * forms, then return the qname repesenting the element type of the array.
       *
       * JAX-RPC Style 2:
       *<xsd:complexType name="hobbyArray">
       *  <xsd:complexContent>
       *    <xsd:restriction base="soapenc:Array">
       *      <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
       *    </xsd:restriction>
       *  </xsd:complexContent>
       *</xsd:complexType>
       *
       * JAX-RPC Style 3:
       *<xsd:complexType name="petArray">
       *  <xsd:complexContent>
       *    <xsd:restriction base="soapenc:Array">
       *      <xsd:sequence>
       *        <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/>
       *      </xsd:sequence>
       *    </xsd:restriction>
       *  </xsd:complexContent>
       *</xsd:complexType>
       *
       */
      private static QName getArrayElementQName_JAXRPC(Node node) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive into it.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
              NodeList children = node.getChildNodes();
              Node complexNode = null;
              for (int j = 0; j < children.getLength() && complexNode == null; j++) {
                  QName complexKind = Utils.getNodeQName(children.item(j));
                  if (complexKind != null &&
                      complexKind.getLocalPart().equals("complexType") &&
                      Utils.isSchemaNS(complexKind.getNamespaceURI())) {
                      complexNode = children.item(j);
                      node = complexNode;
                  }
              }
          }
          // Get the node kind, expecting a schema complexType
          nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("complexType") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Under the complexType there should be a complexContent.
              // (There may be other #text nodes, which we will ignore).
              NodeList children = node.getChildNodes();
              Node complexContentNode = null;
              for (int j = 0; j < children.getLength() && complexContentNode == null; j++) {
                  QName complexContentKind = Utils.getNodeQName(children.item(j));
                  if (complexContentKind != null &&
                      complexContentKind.getLocalPart().equals("complexContent") &&
                      Utils.isSchemaNS(complexContentKind.getNamespaceURI()))
                      complexContentNode = children.item(j);
              }
  
              // Under the complexContent there should be a restriction.
              // (There may be other #text nodes, which we will ignore).
              Node restrictionNode = null;
              if (complexContentNode != null) {
                  children = complexContentNode.getChildNodes();
                  for (int j = 0; j < children.getLength() && restrictionNode == null; j++) {
                      QName restrictionKind = Utils.getNodeQName(children.item(j));
                      if (restrictionKind != null &&
                          restrictionKind.getLocalPart().equals("restriction") &&
                          Utils.isSchemaNS(restrictionKind.getNamespaceURI()))
                          restrictionNode = children.item(j);
                  }
              }
  
              // The restriction node must have a base of soapenc:Array.  
              QName baseType = null;
              if (restrictionNode != null) {
                  baseType = Utils.getNodeTypeRefQName(restrictionNode, "base");
                  if (baseType != null &&
                      baseType.getLocalPart().equals("Array") &&
                      Utils.isSoapEncodingNS(baseType.getNamespaceURI()))
                      ; // Okay
                  else
                      baseType = null;  // Did not find base=soapenc:Array
              }
  
              
              // Under the restriction there should be an attribute OR a sequence/all group node.
              // (There may be other #text nodes, which we will ignore).
              Node groupNode = null;
              Node attributeNode = null;
              if (baseType != null) {
                  children = restrictionNode.getChildNodes();
                  for (int j = 0;
                       j < children.getLength() && groupNode == null && attributeNode == null;
                       j++) {
                      QName kind = Utils.getNodeQName(children.item(j));
                      if (kind != null &&
                          (kind.getLocalPart().equals("sequence") ||
                           kind.getLocalPart().equals("all")) &&
                          Utils.isSchemaNS(kind.getNamespaceURI())) {
                          groupNode = children.item(j);
                      }
                      if (kind != null &&
                          kind.getLocalPart().equals("attribute") &&
                          Utils.isSchemaNS(kind.getNamespaceURI())) {
                          attributeNode = children.item(j);
                      }
                  }
              }
  
              // If there is an attribute node, it must have a ref of soapenc:array and
              // a wsdl:arrayType attribute.
              if (attributeNode != null) {
                  QName refQName = Utils.getNodeTypeRefQName(attributeNode, "ref");
                  if (refQName != null &&
                      refQName.getLocalPart().equals("arrayType") &&
                      Utils.isSoapEncodingNS(refQName.getNamespaceURI()))
                      ; // Okay
                  else
                      refQName = null;  // Did not find ref="soapenc:arrayType"
  
                  String wsdlArrayTypeValue = null;
                  if (refQName != null) {
                      Vector attrs = Utils.getAttributesWithLocalName(attributeNode, "arrayType");
                      for (int i=0; i < attrs.size() && wsdlArrayTypeValue == null; i++) {
                          Node attrNode = (Node) attrs.elementAt(i);
                          String attrName = attrNode.getNodeName();
                          QName attrQName = Utils.getQNameFromPrefixedName(attributeNode, attrName);
                          if (Utils.isWsdlNS(attrQName.getNamespaceURI())) {
                              wsdlArrayTypeValue = attrNode.getNodeValue();
                          }
                      }
                  }
                  
                  // The value should have [] on the end, strip these off.
                  // The convert the prefixed name into a qname, and return
                  if (wsdlArrayTypeValue != null) {
                      int i = wsdlArrayTypeValue.indexOf("[");
                      if (i > 0) {
                          String prefixedName = wsdlArrayTypeValue.substring(0,i);
                          return Utils.getQNameFromPrefixedName(restrictionNode, prefixedName);
                      }
                  }
              } else if (groupNode != null) {
  
                  // Get the first element node under the group node.       
                  NodeList elements = groupNode.getChildNodes();
                  Node elementNode = null;
                  for (int i=0; i < elements.getLength() && elementNode == null; i++) {
                      QName elementKind = Utils.getNodeQName(elements.item(i));
                      if (elementKind != null &&
                          elementKind.getLocalPart().equals("element") &&
                          Utils.isSchemaNS(elementKind.getNamespaceURI())) {
                          elementNode = elements.item(i);
                      }
                  }
                   
                  // The element node should have maxOccurs="unbounded" and
                  // a type
                  if (elementNode != null) {
                      String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs");
                      if (maxOccursValue != null &&
                          maxOccursValue.equalsIgnoreCase("unbounded")) {
                          // Get the QName of just the type
                          return Utils.getNodeTypeRefQName(elementNode, "type");
                      }
                  }
              }
              
          }
          return null;
      }
  
      /**
       * If the specified node represents an array encoding of one of the following
       * forms, then return the qname repesenting the element type of the array.
       *
       * Microsoft Encoding #1:
       *<xsd:complexType name="billArray">
       *      <xsd:sequence>
       *        <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/>
       *      </xsd:sequence>
       *</xsd:complexType>
       *
       * Microsoft Encoding #2:
       *<xsd:complexType name="gatesArray">
       *        <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/>
       *</xsd:complexType>
       *
       */
      private static QName getArrayElementQName_nonJAXRPC(Node node) {
          if (node == null) {
              return null;
          }
  
          // If the node kind is an element, dive into it.
          QName nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("element") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
              NodeList children = node.getChildNodes();
              Node complexNode = null;
              for (int j = 0; j < children.getLength() && complexNode == null; j++) {
                  QName complexKind = Utils.getNodeQName(children.item(j));
                  if (complexKind != null &&
                      complexKind.getLocalPart().equals("complexType") &&
                      Utils.isSchemaNS(complexKind.getNamespaceURI())) {
                      complexNode = children.item(j);
                      node = complexNode;
                  }
              }
          }
          // Get the node kind, expecting a schema complexType
          nodeKind = Utils.getNodeQName(node);
          if (nodeKind != null &&
              nodeKind.getLocalPart().equals("complexType") &&
              Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
              // Inder the complexType there could be a group node.
              // (There may be other #text nodes, which we will ignore).
              NodeList children = node.getChildNodes();
              Node groupNode = null;
              for (int j = 0;
                   j < children.getLength() && groupNode == null;
                   j++) {
                  QName kind = Utils.getNodeQName(children.item(j));
                  if (kind != null &&
                             (kind.getLocalPart().equals("sequence") ||
                              kind.getLocalPart().equals("all")) &&
                             Utils.isSchemaNS(kind.getNamespaceURI())) {
                      groupNode = children.item(j);
                  }
              }
  
              // If a group node, a single element should be underneath
              if (groupNode != null) {
                  children = groupNode.getChildNodes();
              }
  
              // Now get the element node.  There can only be one element node.      
              Node elementNode = null;
              int elementNodeCount = 0;
              for (int i=0; i < children.getLength(); i++) {
                  QName elementKind = Utils.getNodeQName(children.item(i));
                  if (elementKind != null &&
                      elementKind.getLocalPart().equals("element") &&
                      Utils.isSchemaNS(elementKind.getNamespaceURI())) {
                      elementNode = children.item(i);
                      elementNodeCount++;
                  }
              }
  
              // The single element node should have maxOccurs="unbounded" and a type
              if (elementNodeCount == 1) {
                  String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs");
                  if (maxOccursValue != null &&
                      maxOccursValue.equalsIgnoreCase("unbounded")) {
                      return Utils.getNodeTypeRefQName(elementNode, "type");
                  }
              }
          }
          return null;
      }
  
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/ServiceEntry.java
  
  Index: ServiceEntry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  /**
  * This class represents a WSDL service.  It simply encompasses the WSDL4J Service object so it can
  * reside in the SymbolTable.
  */
  public class ServiceEntry extends SymTabEntry {
      private Service service;
  
      /**
       * Construct a ServiceEntry from a WSDL4J Service object.
       */
      public ServiceEntry(Service service) {
          super(service.getQName());
          this.service = service;
      } // ctor
  
      /**
       * Get this entry's Service object.
       */
      public Service getService() {
          return service;
      } // getService
  } // class ServiceEntry
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/SymTabEntry.java
  
  Index: SymTabEntry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import java.util.HashMap;
  
  import javax.wsdl.QName;
  
  /**
  * SymTabEntry is the base class for all symbol table entries.  It contains four things:
  * - a QName
  * - space for a Writer-specific name (for example, in Wsdl2java, this will be the Java name)
  * - isReferenced flag indicating whether this entry is referenced by other entries
  * - dynamicVars; a mechanism for Writers to add additional context information onto entries.
  */
  public abstract class SymTabEntry {
      // The QName of this entry is immutable.  There is no setter for  it.
      protected QName qname;
  
      // The name is Writer implementation dependent.  For example, in Wsdl2java, this will become
      // the Java name.
      protected String name;
  
      // Is this entry referenced by any other entry?
      private boolean isReferenced = false;
  
      private HashMap dynamicVars = new HashMap();
  
      protected SymTabEntry(QName qname) {
          this.qname = qname;
      } // ctor
  
      protected SymTabEntry(QName qname, String name) {
          this.qname = qname;
          this.name = name;
      } // ctor
  
      /**
       * Get the QName of this entry.
       */
      public QName getQName() {
          return qname;
      } // getQName
  
      /**
       * Get the name of this entry.  The name is Writer-implementation-dependent.  For example, in
       * Wsdl2java, this will become the Java name.
       */
      public String getName() {
          return name;
      } // getName
  
      /**
       * Set the name of this entry.  This method is not called by the framework, it is only called
       * by the Writer implementation.
       */
      public void setName(String name) {
          this.name = name;
      } // setName
  
      /**
       * Is this entry referenced by any other entry in the symbol table?
       */
      public boolean isReferenced() {
          return isReferenced;
      } // isReferenced
  
      /**
       * Set the isReferenced variable, default value is true.
       */
      public void setIsReferenced(boolean isReferenced) {
          this.isReferenced = isReferenced;
      } // setIsReferenced
  
      /**
       * There may be information that does not exist in WSDL4J/DOM structures and does not exist in
       * our additional structures, but that thw Writer implementation will need.  This information is
       * most likely context-relative, so the DynamicVar map is provided for the Writers to store/
       * retrieve their particular information.
       */
      public Object getDynamicVar(Object key) {
          return dynamicVars.get(key);
      } // getDynamicVar
  
      public void setDynamicVar(Object key, Object value) {
          dynamicVars.put(key, value);
      } // setDynamicVar
  
      /**
       * Collate the info in this object in string form.
       */
      public String toString() {
          return "QName:         " + qname + '\n' + 
                 "name:          " + name + '\n' + 
                 "isReferenced?  " + isReferenced + '\n';
      } // toString
  } // abstract class SymTabEntry
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Vector;
  
  import javax.wsdl.Binding;
  import javax.wsdl.BindingFault;
  import javax.wsdl.BindingOperation;
  import javax.wsdl.Definition;
  import javax.wsdl.Fault;
  import javax.wsdl.Import;
  import javax.wsdl.Input;
  import javax.wsdl.Message;
  import javax.wsdl.Operation;
  import javax.wsdl.Output;
  import javax.wsdl.Part;
  import javax.wsdl.Port;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  
  import javax.wsdl.extensions.http.HTTPBinding;
  import javax.wsdl.extensions.soap.SOAPBinding;
  import javax.wsdl.extensions.soap.SOAPBody;
  
  import org.apache.axis.utils.JavaUtils;
  import org.apache.axis.utils.XMLUtils;
  
  import org.w3c.dom.Document;
  import org.w3c.dom.NamedNodeMap;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
  * This class represents a table of all of the top-level symbols from a set of WSDL Definitions and
  * DOM Documents:  XML types; WSDL messages, portTypes, bindings, and services.
  *
  * This symbolTable contains entries of the form <key, value> where key is of type QName and value is
  * of type Vector.  The Vector's elements are all of the objects that have the given QName.  This is
  * necessary since names aren't unique among the WSDL types.  message, portType, binding, service,
  * could all have the same QName and are differentiated merely by type.  SymbolTable contains
  * type-specific getters to bypass the Vector layer:
  *   public PortTypeEntry getPortTypeEntry(QName name), etc.
  */
  public class SymbolTable {
      // Mapping from Namespace to Java Package
      private Namespaces namespaces;
  
      // Should the contents of imported files be added to the symbol table?
      private boolean addImports;
  
      // The actual symbol table.  This symbolTable contains entries of the form
      // <key, value> where key is of type QName and value is of type Vector.  The
      // Vector's elements are all of the objects that have the given QName.  This
      // is necessary since names aren't unique among the WSDL types.  message,
      // portType, binding, service, could all have the same QName and are
      // differentiated merely by type.  SymbolTable contains type-specific
      // getters to bypass the Vector layer:
      // public PortTypeEntry getPortTypeEntry(QName name), etc.
  
      private HashMap symbolTable = new HashMap();
  
      // A list of the Type elements in the symbol table
      private Vector types = new Vector();
  
      private boolean debug = false;
  
      /**
       * Construct a symbol table with the given Namespaces.
       */
      public SymbolTable(Namespaces namespaces, boolean addImports, boolean debug) {
          this.namespaces = namespaces;
          this.addImports = addImports;
          this.debug = debug;
      } // ctor
  
      /**
       * Add the given Definition and Document information to the symbol table (including imported
       * symbols), populating it with SymTabEntries for each of the top-level symbols.  When the
       * symbol table has been populated, iterate through it, setting the isReferenced flag
       * appropriately for each entry.
       */
      protected void add(Definition def, Document doc) throws IOException {
          checkForUndefined(def);
          populate(def, doc);
          setReferences(def, doc);
          checkForUndefined();
      } // add
  
      /**
       * Scan the Definition for undefined objects and throw an error.
       */ 
      private void checkForUndefined(Definition def) throws IOException {
          if (def != null) {
              // Bindings
              Iterator ib = def.getBindings().values().iterator();
              while (ib.hasNext()) {
                  Binding binding = (Binding) ib.next();
                  if (binding.isUndefined()) {
                      throw new IOException(
                              JavaUtils.getMessage("emitFailtUndefinedBinding01",
                                      binding.getQName().getLocalPart()));
                  }
              }
  
              // portTypes
              Iterator ip = def.getPortTypes().values().iterator();
              while (ip.hasNext()) {
                  PortType portType = (PortType) ip.next();
                  if (portType.isUndefined()) {
                      throw new IOException(
                              JavaUtils.getMessage("emitFailtUndefinedPort01",
                                      portType.getQName().getLocalPart()));
                  }
              }
              
  /* tomj: This is a bad idea, faults seem to be undefined
              // Messages
              Iterator i = def.getMessages().values().iterator();
              while (i.hasNext()) {
                  Message message = (Message) i.next();
                  if (message.isUndefined()) {
                      throw new IOException(
                              JavaUtils.getMessage("emitFailtUndefinedMessage01",
                                      message.getQName().getLocalPart()));
                  }
              }
  */
          }
      }
  
      /**
       * Scan the symbol table for undefined types and throw an exception.
       */
      private void checkForUndefined() throws IOException {
          Iterator it = symbolTable.values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  if (v.get(i) instanceof RefdType) {
                      throw new IOException(
                              JavaUtils.getMessage("undefined00",
                              "" + ((RefdType)v.get(i)).getQName()));
                  }
              }
          }
      } // checkForUndefined
  
      /**
       * Add the given Definition and Document information to the symbol table (including imported
       * symbols), populating it with SymTabEntries for each of the top-level symbols.
       */
      private HashSet importedFiles = new HashSet();
      private void populate(Definition def, Document doc) throws IOException {
          if (doc != null) {
              populateTypes(doc);
  
              // If def == null, then WSDL4J doesn't provide any import logic
              // for this xml file.  Recurse on Document imports rather than
              // Definition imports.
              if (def == null && addImports) {
                  // Recurse through children nodes, looking for imports
                  lookForImports(doc);
              }
          }
          if (def != null) {
              if (addImports) {
                  // Add the symbols from the imported WSDL documents
                  Map imports = def.getImports();
                  Object[] importKeys = imports.keySet().toArray();
                  for (int i = 0; i < importKeys.length; ++i) {
                      Vector v = (Vector) imports.get(importKeys[i]);
                      for (int j = 0; j < v.size(); ++j) {
                          Import imp = (Import) v.get(j);
                          if (!importedFiles.contains(imp.getLocationURI())) {
                              importedFiles.add(imp.getLocationURI());
                              populate(imp.getDefinition(),
                                      XMLUtils.newDocument(imp.getLocationURI()));
                          }
                      }
                  }
              }
              populateMessages(def);
              populatePortTypes(def);
              populateBindings(def);
              populateServices(def);
          }
      } // populate
  
      /**
       * Recursively find all import objects and call populate for each one.
       */
      private void lookForImports(Node node) throws IOException {
          NodeList children = node.getChildNodes();
          for (int i = 0; i < children.getLength(); i++) {
              Node child = children.item(i);
              if ("import".equals(child.getLocalName())) {
                  NamedNodeMap attributes = child.getAttributes();
                  Node importFile = attributes.getNamedItem("schemaLocation");
                  if (importFile != null) {
                      populate(null,
                              XMLUtils.newDocument(importFile.getNodeValue()));
                  }
              }
              lookForImports(child);
          }
      } // lookForImports
  
      /**
       * Populate the symbol table with all of the Types from the Document.
       */
      private void populateTypes(Document doc) throws IOException {
          addTypes(doc, ABOVE_SCHEMA_LEVEL);
      } // populateTypes
  
      /**
       * Utility method which walks the Document and creates Type objects for
       * each complexType, simpleType, or element referenced or defined.
       *
       * What goes into the symbol table?  In general, only the top-level types (ie., those just below
       * the schema tag).  But base types and references can appear below the top level.  So anything
       * at the top level is added to the symbol table, plus non-Element types (ie, base and refd)
       * that appear deep within other types.
       */
      private static final int ABOVE_SCHEMA_LEVEL = -1;
      private static final int SCHEMA_LEVEL = 0;
      private void addTypes(Node node, int level) throws IOException {
          if (node == null) {
              return;
          }
          // Get the kind of node (complexType, wsdl:part, etc.)
          QName nodeKind = Utils.getNodeQName(node);
  
          if (nodeKind != null) {
              if (nodeKind.getLocalPart().equals("complexType") &&
                  Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
                  // This is a definition of a complex type.
                  // Create a Type.
                  createTypeFromDef(node, false, false);
              }
              if (nodeKind.getLocalPart().equals("simpleType") &&
                  Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  
                  // This is a definition of a simple type, which could be an enum
                  // Create a Type.
                  createTypeFromDef(node, false, false);
              }
              else if (nodeKind.getLocalPart().equals("element") &&
                     Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
                  // If the element has a type/ref attribute, create
                  // a Type representing the referenced type.
                  if (Utils.getAttribute(node, "type") != null ||
                      Utils.getAttribute(node, "ref") != null) {
                      createTypeFromRef(node);
                  }
  
                  // Create a type representing an element.  (This may
                  // seem like overkill, but is necessary to support ref=
                  // and element=.
                  createTypeFromDef(node, true, level > SCHEMA_LEVEL);
              }
              else if (nodeKind.getLocalPart().equals("part") &&
                       Utils.isWsdlNS(nodeKind.getNamespaceURI())) {
  
                  // This is a wsdl part.  Create an Type representing the reference
                  createTypeFromRef(node);
              }
          }
  
          if (level == ABOVE_SCHEMA_LEVEL) {
              if (nodeKind != null && nodeKind.getLocalPart().equals("schema")) {
                  level = SCHEMA_LEVEL;
              }
          }
          else {
              ++level;
          }
  
          // Recurse through children nodes
          NodeList children = node.getChildNodes();
          for (int i = 0; i < children.getLength(); i++) {
              addTypes(children.item(i), level);
          }
      } // addTypes
  
      /**
       * Create a Type from the indicated node, which defines a type
       * that represents a complexType, simpleType or element (for ref=).
       */
      private void createTypeFromDef(Node node, boolean isElement,
              boolean belowSchemaLevel) throws IOException {
          // If this is not an element, make sure it is not an anonymous type.
          // If it is, the the existing ElementType will be used.  If
          // not, create a new type.
          if (!isElement &&
              Utils.getAttribute(node, "name") == null) {
              return;
          }
  
          // Get the QName of the node's name attribute value
          QName qName = Utils.getNodeNameQName(node);
          if (qName != null) {
              if (debug) {
                  System.out.println("Create Type From Def:" + qName);
              }
  
              map(qName.getNamespaceURI());
  
              // If the node has a type or ref attribute, get the 
              // ultimate ref'd type
              QName refQName = Utils.getNodeTypeRefQName(node);
              if (refQName != null) {
                  // Discover whether type is from a type= or ref=/element=
                  boolean typeAttr = false;
                  if (Utils.getNodeTypeRefQName(node, "type") != null)
                      typeAttr = true;
  
                  Type refType = null;
                  while (refQName != null) {
                      refType = getTypeEntry(refQName, !typeAttr);
                      refQName = null;
                      if (refType != null &&
                          refType.getNode() != null) {
                          refQName = Utils.getNodeTypeRefQName(refType.getNode());
                          typeAttr = false;
                          if (Utils.getNodeTypeRefQName(node, "type") != null)
                              typeAttr = true;
                          // A 'collection' type has a node that refers to itself.
                          // so we need to break out of the loop to avoid an infinite loop.
                          if (refQName != null && refQName.equals(refType.getQName()))
                              refQName = null;
                      }                         
                  }
                  // Create a type from the referenced type
                  if (!belowSchemaLevel && refType != null) {
                      symbolTablePut(new ElementType(qName, refType, node));
                  }
  
              }   
              else {
  
                  // See if this is an array definition.
                  QName arrayQName = SchemaUtils.getArrayElementQName(node);
                  if (arrayQName != null) {
                      String javaName = getJavaName(arrayQName)+"[]";
                      Type arrayType = null;
                      if (isElement) {
                          arrayType = new ElementType(qName, javaName, node);
                      } else {
                          arrayType = new DefinedType(qName, javaName, node);
                      }
                      symbolTablePut(arrayType);
                      arrayType.setShouldEmit(false);
                  }
                  else {
                      // Create a Type representing a base type or non-base type
                      String baseJavaName = Utils.getBaseJavaName(qName);
                      if (baseJavaName != null) {
                          symbolTablePut(new BaseJavaType(qName));
                      }
                      else if (isElement) {
                          symbolTablePut(new ElementType(qName, getJavaName(qName), node));
                      }
                      else {
                          symbolTablePut(new DefinedType(qName, getJavaName(qName), node));
                      }
                  }
              }
          }
      } // createTypeFromDef
      
      /**
       * Node may contain a reference (via type=, ref=, or element= attributes) to 
       * another type.  Create a Type object representing this referenced type.
       */
      private void createTypeFromRef(Node node) throws IOException {
          // Get the QName of the node's type attribute value
          QName qName = Utils.getNodeTypeRefQName(node);
          if (qName != null) {
  
              // Discover whether type is from a type= or ref=/element=
              boolean typeAttr = false;
              if (Utils.getNodeTypeRefQName(node, "type") != null)
                  typeAttr = true;
  
              // Get Type or ElementType depending on whether type attr was used.
              Type type = getTypeEntry(qName, !typeAttr);
              String javaName = getJavaName(qName);
  
              // A symbol table entry is only created if type= and the type is not
              // found
              if (type == null && typeAttr) {
                  // Type not defined, add a base java type or a refdType
                  if (debug) {
                      System.out.println("Create Type From Ref:" + qName);
                  }
                  String baseJavaName = Utils.getBaseJavaName(qName);
                  if (baseJavaName != null)
                      symbolTablePut(new BaseJavaType(qName));
                  else if (javaName.indexOf("[") > 0)
                      symbolTablePut(new CollectionType(qName, javaName, node));
                  else 
                      symbolTablePut(new RefdType(qName, javaName));
              } else {
                  // Type exists, update shouldEmit flag if necessary
                  if (type instanceof ElementType &&
                      type.isDefined() &&
                      type.getJavaName().indexOf("[") < 0 &&
                      ((ElementType) type).getDefinedDirectly()) {
                      type.setShouldEmit(true);
                  }
              }
                  
          }
      } // createTypeFromRef
  
      /**
       * Convert the specified QName into a full Java Name.
       */
      public String getJavaName(QName qName) {
  
          // If this is one of our special 'collection' qnames.
          // get the element type and append []
          if (qName.getLocalPart().indexOf("[") > 0) {
              String localPart = qName.getLocalPart().substring(0,qName.getLocalPart().indexOf("["));
              QName eQName = new QName(qName.getNamespaceURI(), localPart);
              return getJavaName(eQName) + "[]";
          }
  
          // Handle the special "java" namespace for types
          if (qName.getNamespaceURI().equalsIgnoreCase("java")) {
              return qName.getLocalPart();
          }
  
          // The QName may represent a base java name, so check this first
          String fullJavaName = Utils.getBaseJavaName(qName);
          if (fullJavaName != null) 
              return fullJavaName;
          
          // Use the namespace uri to get the appropriate package
          String pkg = getPackage(qName.getNamespaceURI());
          if (pkg != null) {
              fullJavaName = pkg + "." + Utils.xmlNameToJavaClass(qName.getLocalPart());
          } else {
              fullJavaName = Utils.xmlNameToJavaClass(qName.getLocalPart());
          }
          return fullJavaName;
      } // getJavaName
  
      /**
       * Populate the symbol table with all of the MessageEntry's from the Definition.
       */
      private void populateMessages(Definition def) throws IOException {
          Iterator i = def.getMessages().values().iterator();
          while (i.hasNext()) {
              Message message = (Message) i.next();
              MessageEntry mEntry = new MessageEntry(message);
              symbolTablePut(mEntry);
          }
      } // populateMessages
  
      /**
       * Populate the symbol table with all of the PortTypeEntry's from the Definition.
       */
      private void populatePortTypes(Definition def) throws IOException {
          Iterator i = def.getPortTypes().values().iterator();
          while (i.hasNext()) {
              PortType portType = (PortType) i.next();
  
              // If the portType is undefined, then we're parsing a Definition
              // that didn't contain a portType, merely a binding that referred
              // to a non-existent port type.  Don't bother with it.
              if (!portType.isUndefined()) {
                  HashMap parameters = new HashMap();
  
                  // Remove Duplicates - happens with only a few WSDL's. No idea why!!! 
                  // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) 
                  // TODO: Remove this patch...
                  // NOTE from RJB:  this is a WSDL4J bug and the WSDL4J guys have been notified.
                  Iterator operations = (new HashSet(portType.getOperations())).iterator();
  
                  while(operations.hasNext()) {
                      Operation operation = (Operation) operations.next();
                      String namespace = portType.getQName().getNamespaceURI();
                      Parameters parms = parameters(operation, namespace);
                      parameters.put(operation.getName(), parms);
                  }
                  PortTypeEntry ptEntry = new PortTypeEntry(portType, parameters);
                  symbolTablePut(ptEntry);
              }
          }
      } // populatePortTypes
  
      /**
       * For the given operation, this method returns the parameter info conveniently collated.
       * There is a bit of processing that is needed to write the interface, stub, and skeleton.
       * Rather than do that processing 3 times, it is done once, here, and stored in the
       * Parameters object.
       */
      private Parameters parameters(Operation operation, String namespace) throws IOException {
          Parameters parameters = new Parameters();
  
          // The input and output Vectors, when filled in, will be of the form:
          // {<parmType0>, <parmName0>, <parmType1>, <parmName1>, ..., <parmTypeN>, <parmNameN>}
          Vector inputs = new Vector();
          Vector outputs = new Vector();
  
          List parameterOrder = operation.getParameterOrdering();
  
          // Handle parameterOrder="", which is techinically illegal
          if (parameterOrder != null && parameterOrder.isEmpty()) {
              parameterOrder = null;
          }
  
          // All input parts MUST be in the parameterOrder list.  It is an error otherwise.
          if (parameterOrder != null) {
              Input input = operation.getInput();
              if (input != null) {
                  Message inputMsg = input.getMessage();
                  Map allInputs = inputMsg.getParts();
                  Collection orderedInputs = inputMsg.getOrderedParts(parameterOrder);
                  if (allInputs.size() != orderedInputs.size()) {
                      throw new IOException(JavaUtils.getMessage("emitFail00", operation.getName()));
                  }
              }
          }
  
          // Collect all the input parameters
          Input input = operation.getInput();
          if (input != null) {
              partStrings(inputs,
                      input.getMessage().getOrderedParts(null));
          }
  
          // Collect all the output parameters
          Output output = operation.getOutput();
          if (output != null) {
              partStrings(outputs,
                      output.getMessage().getOrderedParts(null));
          }
  
          if (parameterOrder != null) {
              // Construct a list of the parameters in the parameterOrder list, determining the
              // mode of each parameter and preserving the parameterOrder list.
              for (int i = 0; i < parameterOrder.size(); ++i) {
                  String name = (String) parameterOrder.get(i);
  
                  // index in the inputs Vector of the given name, -1 if it doesn't exist.
                  int index = getPartIndex(name, inputs);
  
                  // index in the outputs Vector of the given name, -1 if it doesn't exist.
                  int outdex = getPartIndex(name, outputs);
  
                  if (index > 0) {
                      // The mode of this parameter is either in or inout
                      addInishParm(inputs, outputs, index, outdex, parameters, true);
                  }
                  else if (outdex > 0) {
                      addOutParm(outputs, outdex, parameters, true);
                  }
                  else {
                      System.err.println(JavaUtils.getMessage("noPart00", name));
                  }
              }
          }
  
          // Get the mode info about those parts that aren't in the parameterOrder list.
          // Since they're not in the parameterOrder list, the order doesn't matter.
          // Add the input and inout parts first, then add the output parts.
          for (int i = 1; i < inputs.size(); i += 2) {
              int outdex = getPartIndex((String) inputs.get(i), outputs);
              addInishParm(inputs, outputs, i, outdex, parameters, false);
          }
  
          // Now that the remaining in and inout parameters are collected, the first entry in the
          // outputs Vector is the return value.  The rest are out parameters.
          if (outputs.size() > 0) {
              parameters.returnType = (Type) outputs.get(0);
              parameters.returnName = (String) outputs.get(1);
              ++parameters.outputs;
              for (int i = 3; i < outputs.size(); i += 2) {
                  addOutParm(outputs, i, parameters, false);
              }
          }
  
          // Collect the list of faults into a single string, separated by commas.
          Map faults = operation.getFaults();
          Iterator i = faults.values().iterator();
          while (i.hasNext()) {
              Fault fault = (Fault) i.next();
              String exceptionName = Utils.getExceptionName(fault);
              if (parameters.faultString == null)
                  parameters.faultString = exceptionName;
              else
                  parameters.faultString = parameters.faultString + ", " + exceptionName;
          }
          return parameters;
      } // parameters
  
      /**
       * Return the index of the given name in the given Vector, -1 if it doesn't exist.
       */
      private int getPartIndex(String name, Vector v) {
          for (int i = 1; i < v.size(); i += 2) {
              if (name.equals(v.get(i))) {
                  return i;
              }
          }
          return -1;
      } // getPartIndex
  
      /**
       * Add an in or inout parameter to the parameters object.
       */
      private void addInishParm(Vector inputs, Vector outputs, int index, int outdex, Parameters parameters, boolean trimInput) {
          Parameter p = new Parameter();
          p.name = (String) inputs.get(index);
          p.type = (Type) inputs.get(index - 1);
  
          // Should we remove the given parameter type/name entries from the Vector?
          if (trimInput) {
              inputs.remove(index);
              inputs.remove(index - 1);
          }
  
          // At this point we know the name and type of the parameter, and that it's at least an
          // in parameter.  Now check to see whether it's also in the outputs Vector.  If it is,
          // then it's an inout parameter.
          if (outdex > 0 && p.type.equals(outputs.get(outdex - 1))) {
              outputs.remove(outdex);
              outputs.remove(outdex - 1);
              p.mode = Parameter.INOUT;
              ++parameters.inouts;
          }
          else {
              ++parameters.inputs;
          }
          parameters.list.add(p);
      } // addInishParm
  
      /**
       * Add an output parameter to the parameters object.
       */
      private void addOutParm(Vector outputs, int outdex, Parameters parameters, boolean trim) {
          Parameter p = new Parameter();
          p.name = (String) outputs.get(outdex);
          p.type = (Type) outputs.get(outdex - 1);
          if (trim) {
              outputs.remove(outdex);
              outputs.remove(outdex - 1);
          }
          p.mode = Parameter.OUT;
          ++parameters.outputs;
          parameters.list.add(p);
      } // addOutParm
  
      /**
       * This method returns a vector containing the Java types (even indices) and
       * names (odd indices) of the parts.
       */
      protected void partStrings(Vector v, Collection parts) {
          Iterator i = parts.iterator();
  
          while (i.hasNext()) {
              Part part = (Part) i.next();
              QName elementName = part.getElementName();
              QName typeName = part.getTypeName();
              if (typeName != null) {
                  v.add(getTypeEntry(typeName));
                  v.add(part.getName());
              } else if (elementName != null) {
                  v.add(getElementTypeEntry(elementName));
                  v.add(part.getName());
              }
          }
      } // partStrings
  
      /**
       * Populate the symbol table with all of the BindingEntry's from the Definition.
       */
      private void populateBindings(Definition def) throws IOException {
          Iterator i = def.getBindings().values().iterator();
          while (i.hasNext()) {
              int bindingStyle = BindingEntry.STYLE_RPC;
              int bindingType = BindingEntry.TYPE_UNKNOWN;
              Binding binding = (Binding) i.next();
              Iterator extensibilityElementsIterator = binding.getExtensibilityElements().iterator();
              while (extensibilityElementsIterator.hasNext()) {
                  Object obj = extensibilityElementsIterator.next();
                  if (obj instanceof SOAPBinding) {
                      bindingType = BindingEntry.TYPE_SOAP;
                      SOAPBinding sb = (SOAPBinding) obj;
                      String style = sb.getStyle();
                      if (style.equalsIgnoreCase("document")) {
                          bindingStyle = BindingEntry.STYLE_DOCUMENT;
                      }
                  }
                  else if (obj instanceof HTTPBinding) {
                      HTTPBinding hb = (HTTPBinding) obj;
                      if (hb.getVerb().equalsIgnoreCase("post")) {
                          bindingType = BindingEntry.TYPE_HTTP_POST;
                      }
                      else {
                          bindingType = BindingEntry.TYPE_HTTP_GET;
                      }
                  }
              }
  
              // Check the Binding Operations for use="literal"
              HashMap attributes = new HashMap();
              List bindList = binding.getBindingOperations();
              for (Iterator opIterator = bindList.iterator(); opIterator.hasNext();) {
                  int inputBodyType = BindingEntry.USE_ENCODED;
                  int outputBodyType = BindingEntry.USE_ENCODED;
                  BindingOperation bindOp = (BindingOperation) opIterator.next();
  
                  // input
                  if (bindOp.getBindingInput() != null) {
                      if (bindOp.getBindingInput().getExtensibilityElements() != null) {
                          Iterator inIter = bindOp.getBindingInput().getExtensibilityElements().iterator();
                          for (; inIter.hasNext();) {
                              Object obj = inIter.next();
                              if (obj instanceof SOAPBody) {
                                  String use = ((SOAPBody) obj).getUse();
                                  if (use.equalsIgnoreCase("literal")) {
                                      inputBodyType = BindingEntry.USE_LITERAL;
                                  }
                                  break;
                              }
                          }
                      }
                  }
  
                  // output
                  if (bindOp.getBindingOutput() != null) {
                      if (bindOp.getBindingOutput().getExtensibilityElements() != null) {
                          Iterator outIter = bindOp.getBindingOutput().getExtensibilityElements().iterator();
                          for (; outIter.hasNext();) {
                              Object obj = outIter.next();
                              if (obj instanceof SOAPBody) {
                                  String use = ((SOAPBody) obj).getUse();
                                  if (use.equalsIgnoreCase("literal")) {
                                      outputBodyType = BindingEntry.USE_LITERAL;
                                  }
                                  break;
                              }
                          }
                      }
                  }
  
                  // faults
                  HashMap faultMap = new HashMap();
                  Iterator faultMapIter = bindOp.getBindingFaults().values().iterator();
                  for (; faultMapIter.hasNext(); ) {
                      BindingFault bFault = (BindingFault)faultMapIter.next();
  
                      // Set default entry for this fault
                      String faultName = bFault.getName();
                      int faultBodyType = BindingEntry.USE_ENCODED;
  
                      Iterator faultIter =
                              bFault.getExtensibilityElements().iterator();
                      for (; faultIter.hasNext();) {
                          Object obj = faultIter.next();
                          if (obj instanceof SOAPBody) {
                              String use = ((SOAPBody) obj).getUse();
                              if (use.equalsIgnoreCase("literal")) {
                                  faultBodyType = BindingEntry.USE_LITERAL;
                              }
                              break;
                          }
                      }
                      // Add this fault name and bodyType to the map
                      faultMap.put(faultName, new Integer(faultBodyType));
                  }
                  // Associate the portType operation that goes with this binding
                  // with the body types.
                  attributes.put(bindOp.getOperation(),
                          new BindingEntry.OperationAttr(inputBodyType, outputBodyType, faultMap));
  
              } // binding operations
  
              BindingEntry bEntry = new BindingEntry(binding, bindingType, bindingStyle, attributes);
              symbolTablePut(bEntry);
          }
      } // populateBindings
  
      /**
       * Populate the symbol table with all of the ServiceEntry's from the Definition.
       */
      private void populateServices(Definition def) throws IOException {
          Iterator i = def.getServices().values().iterator();
          while (i.hasNext()) {
              Service service = (Service) i.next();
              ServiceEntry sEntry = new ServiceEntry(service);
              symbolTablePut(sEntry);
          }
      } // populateServices
  
      /**
       * Set each SymTabEntry's isReferenced flag.  The default is false.  If no other symbol
       * references this symbol, then leave it false, otherwise set it to true.
       */
      private void setReferences(Definition def, Document doc) {
          Map stuff = def.getServices();
          if (stuff.isEmpty()) {
              stuff = def.getBindings();
              if (stuff.isEmpty()) {
                  stuff = def.getPortTypes();
                  if (stuff.isEmpty()) {
                      stuff = def.getMessages();
                      if (stuff.isEmpty()) {
                          for (int i = 0; i < types.size(); ++i) {
                              Type type = (Type) types.get(i);
                              setTypeReferences(type, doc);
                          }
                      }
                      else {
                          Iterator i = stuff.values().iterator();
                          while (i.hasNext()) {
                              Message message = (Message) i.next();
                              MessageEntry mEntry =
                                      getMessageEntry(message.getQName());
                              setMessageReferences(mEntry, def, doc);
                          }
                      }
                  }
                  else {
                      Iterator i = stuff.values().iterator();
                      while (i.hasNext()) {
                          PortType portType = (PortType) i.next();
                          PortTypeEntry ptEntry =
                                  getPortTypeEntry(portType.getQName());
                          setPortTypeReferences(ptEntry, def, doc);
                      }
                  }
              }
              else {
                  Iterator i = stuff.values().iterator();
                  while (i.hasNext()) {
                      Binding binding = (Binding) i.next();
                      BindingEntry bEntry = getBindingEntry(binding.getQName());
                      setBindingReferences(bEntry, def, doc);
                  }
              }
          }
          else {
              Iterator i = stuff.values().iterator();
              while (i.hasNext()) {
                  Service service = (Service) i.next();
                  ServiceEntry sEntry = getServiceEntry(service.getQName());
                  setServiceReferences(sEntry, def, doc);
              }
          }
      } // setReferences
  
      private void setTypeReferences(Type entry, Document doc) {
          // If we don't want to emit stuff from imported files, only set the
          // isReferenced flag if this entry exists in the immediate WSDL file.
          Node node = entry.getNode();
          if (addImports || node == null || node.getOwnerDocument() == doc) {
              entry.setIsReferenced(true);
              if (entry instanceof ElementType) {
                  QName referentName = Utils.getNodeTypeRefQName(entry.getNode());
                  if (referentName != null) {
                      // Discover whether type is from a type= or ref=/element=
                      boolean typeAttr = false;
                      if (Utils.getNodeTypeRefQName(entry.getNode(), "type") != null)
                          typeAttr = true;
  
                      Type referent = getTypeEntry(referentName, !typeAttr);
                      if (referent != null) {
                          setTypeReferences(referent, doc);
                      }
                  }
              }
          }
  
          HashSet nestedTypes = Utils.getNestedTypes(node, this);
          Iterator it = nestedTypes.iterator();
          while (it.hasNext()) {
              Type nestedType = (Type) it.next();
              if (!nestedType.isReferenced()) {
                  setTypeReferences(nestedType, doc);
              }
          }
      } // setTypeReferences
  
      /**
       * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers to.
       */
      private void setMessageReferences(
              MessageEntry entry, Definition def, Document doc) {
          // If we don't want to emit stuff from imported files, only set the
          // isReferenced flag if this entry exists in the immediate WSDL file.
          Message message = entry.getMessage();
          if (addImports) {
              entry.setIsReferenced(true);
          }
          else {
              // NOTE:  I thought I could have simply done:
              // if (def.getMessage(message.getQName()) != null)
              // but that method traces through all imported messages.
              Map messages = def.getMessages();
              if (messages.containsValue(message)) {
                  entry.setIsReferenced(true);
              }
          }
  
          // Set all the message's types
          Iterator parts = message.getParts().values().iterator();
          while (parts.hasNext()) {
              Part part = (Part) parts.next();
              Type type = getTypeEntry(part.getTypeName());
              if (type != null) {
                  setTypeReferences(type, doc);
              }
              type = getElementTypeEntry(part.getElementName());
              if (type != null) {
                  setTypeReferences(type, doc);
              }
          }
      } // setMessageReference
  
      /**
       * Set the isReferenced flag to true on all SymTabEntries that the given PortType refers to.
       */
      private void setPortTypeReferences(
              PortTypeEntry entry, Definition def, Document doc) {
          // If we don't want to emit stuff from imported files, only set the
          // isReferenced flag if this entry exists in the immediate WSDL file.
          PortType portType = entry.getPortType();
          if (addImports) {
              entry.setIsReferenced(true);
          }
          else {
              // NOTE:  I thought I could have simply done:
              // if (def.getPortType(portType.getQName()) != null)
              // but that method traces through all imported portTypes.
              Map portTypes = def.getPortTypes();
              if (portTypes.containsValue(portType)) {
                  entry.setIsReferenced(true);
              }
          }
  
          // Set all the portType's messages
          Iterator operations = portType.getOperations().iterator();
  
          // For each operation, query its input, output, and fault messages
          while (operations.hasNext()) {
              Operation operation = (Operation) operations.next();
  
              // Query the input message
              Input input = operation.getInput();
              if (input != null) {
                  Message message = input.getMessage();
                  if (message != null) {
                      MessageEntry mEntry = getMessageEntry(message.getQName());
                      if (mEntry != null) {
                          setMessageReferences(mEntry, def, doc);
                      }
                  }
              }
  
              // Query the output message
              Output output = operation.getOutput();
              if (output != null) {
                  Message message = output.getMessage();
                  if (message != null) {
                      MessageEntry mEntry = getMessageEntry(message.getQName());
                      if (mEntry != null) {
                          setMessageReferences(mEntry, def, doc);
                      }
                  }
              }
  
              // Query the fault messages
              Iterator faults =
                operation.getFaults().values().iterator();
              while (faults.hasNext()) {
                  Message message = ((Fault) faults.next()).getMessage();
                  if (message != null) {
                      MessageEntry mEntry = getMessageEntry(message.getQName());
                      if (mEntry != null) {
                          setMessageReferences(mEntry, def, doc);
                      }
                  }
              }
          }
      } // setPortTypeReferences
  
      /**
       * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers to.
       */
      private void setBindingReferences(
              BindingEntry entry, Definition def, Document doc) {
          // If we don't want to emit stuff from imported files, only set the
          // isReferenced flag if this entry exists in the immediate WSDL file.
          Binding binding = entry.getBinding();
          if (addImports) {
              entry.setIsReferenced(true);
          }
          else {
              // NOTE:  I thought I could have simply done:
              // if (def.getBindng(binding.getQName()) != null)
              // but that method traces through all imported bindings.
              Map bindings = def.getBindings();
              if (bindings.containsValue(binding)) {
                  entry.setIsReferenced(true);
              }
          }
  
          // Set all the binding's portTypes
          PortType portType = binding.getPortType();
          PortTypeEntry ptEntry = getPortTypeEntry(portType.getQName());
          if (ptEntry != null) {
              setPortTypeReferences(ptEntry, def, doc);
          }
      } // setBindingReferences
  
      /**
       * Set the isReferenced flag to true on all SymTabEntries that the given Meesage refers to.
       */
      private void setServiceReferences(
              ServiceEntry entry, Definition def, Document doc) {
          // If we don't want to emit stuff from imported files, only set the
          // isReferenced flag if this entry exists in the immediate WSDL file.
          Service service = entry.getService();
          if (addImports) {
              entry.setIsReferenced(true);
          }
          else {
              // NOTE:  I thought I could have simply done:
              // if (def.getService(service.getQName()) != null)
              // but that method traces through all imported services.
              Map services = def.getServices();
              if (services.containsValue(service)) {
                  entry.setIsReferenced(true);
              }
          }
  
          // Set all the service's bindings
          Iterator ports = service.getPorts().values().iterator();
          while (ports.hasNext()) {
              Port port = (Port) ports.next();
              Binding binding = (Binding) port.getBinding();
              BindingEntry bEntry = getBindingEntry(binding.getQName());
              if (bEntry != null) {
                  setBindingReferences(bEntry, def, doc);
              }
          }
      } // setServiceReferences
  
      /**
       * Put the given SymTabEntry into the symbol table, if appropriate.  
       */
      private void symbolTablePut(SymTabEntry entry) throws IOException {
          QName name = entry.getQName();
          if (get(name, entry.getClass()) == null) {
              // An entry of the given qname of the given type doesn't exist yet.
  
              if (entry instanceof Type && get(name, RefdType.class) != null) {
                  // A referenced entry exists in the symbol table, which means
                  // that the type is used, but we don't yet have a definition for
                  // the type.  Now we DO have a definition for the type, so
                  // replace the existing referenced type with the real type.
                  Vector v = (Vector) symbolTable.get(name);
                  for (int i = 0; i < v.size(); ++i) {
                      Object oldEntry = v.elementAt(i);
                      if (oldEntry instanceof RefdType) {
  
                          // Replace it in the symbol table
                          v.setElementAt(entry, i);
  
                          // Replace it in the types Vector
                          for (int j = 0; j < types.size(); ++j) {
                              if (types.elementAt(j) == oldEntry) {
                                  types.setElementAt(entry, j);
                              }
                          }
                      }
                  }
              }
              else {
                  // Add this entry to the symbol table
                  Vector v = (Vector) symbolTable.get(name);
                  if (v == null) {
                      v = new Vector();
                      symbolTable.put(name, v);
                  }
                  v.add(entry);
                  if (entry instanceof Type) {
                      types.add(entry);
                  }
              }
          }
          else {
              throw new IOException(
                      JavaUtils.getMessage("alreadyExists00", "" + name));
          }
      } // symbolTablePut
  
      /**
       * Get the raw symbol table HashMap.
       */
      public HashMap getHashMap() {
          return symbolTable;
      } // getHashMap
  
      /**
       * Get the list of entries with the given QName.  Since symbols can share QNames, this list is
       * necessary.  This list will not contain any more than one element of any given SymTabEntry.
       */
      public Vector getSymbols(QName qname) {
          return (Vector) symbolTable.get(qname);
      } // get
  
      /**
       * Get the entry with the given QName of the given class.  If it does not exist, return null.
       */
      private SymTabEntry get(QName qname, Class cls) {
          Vector v = (Vector) symbolTable.get(qname);
          if (v == null) {
              return null;
          }
          else {
              for (int i = 0; i < v.size(); ++i) {
                  SymTabEntry entry = (SymTabEntry) v.elementAt(i);
                  if (cls.isInstance(entry)) {
                      return entry;
                  }
              }
              return null;
          }
      } // get
  
  
      /**
       * Get the type entry for the given qname.
       * @param qname
       * @param wantElementType boolean that indicates type or element (for type= or ref=)
       */
      public Type getTypeEntry(QName qname, boolean wantElementType) {
          if (wantElementType) {
              return getElementTypeEntry(qname);
          } else
              return getTypeEntry(qname);
      } // getTypeEntry
  
      /**
       * Get the non-ElementType TypeEntry with the given QName.  If it doesn't exist, return null.
       */
      public Type getTypeEntry(QName qname) {
          for (int i = 0; i < types.size(); ++i) {
              Type type = (Type) types.get(i);
              if (type.getQName().equals(qname)
                      && !(type instanceof ElementType)) {
                  return type;
              }
          }
          return null;
      } // getTypeEntry
  
      /**
       * Get the ElementType entry with the given QName.  If it doesn't exist, return null.
       */
      public ElementType getElementTypeEntry(QName qname) {
          for (int i = 0; i < types.size(); ++i) {
              Type type = (Type) types.get(i);
              if (type.getQName().equals(qname) && type instanceof ElementType) {
                  return (ElementType) type;
              }
          }
          return null;
      } // getElementTypeEntry
  
      /**
       * Get the MessageEntry with the given QName.  If it doesn't exist, return null.
       */
      public MessageEntry getMessageEntry(QName qname) {
          return (MessageEntry) get(qname, MessageEntry.class);
      } // getMessageEntry
  
      /**
       * Get the PortTypeEntry with the given QName.  If it doesn't exist, return null.
       */
      public PortTypeEntry getPortTypeEntry(QName qname) {
          return (PortTypeEntry) get(qname, PortTypeEntry.class);
      } // getPortTypeEntry
  
      /**
       * Get the BindingEntry with the given QName.  If it doesn't exist, return null.
       */
      public BindingEntry getBindingEntry(QName qname) {
          return (BindingEntry) get(qname, BindingEntry.class);
      } // getBindingEntry
  
      /**
       * Get the ServiceEntry with the given QName.  If it doesn't exist, return null.
       */
      public ServiceEntry getServiceEntry(QName qname) {
          return (ServiceEntry) get(qname, ServiceEntry.class);
      } // getServiceEntry
  
      /**
       * Get the list of all the XML schema types in the symbol table.  In other words, all entries
       * that are instances of TypeEntry.
       */
      public Vector getTypes() {
          return types;
      } // getTypes
  
      /**
       * Invoke this method to associate a namespace URI with a autogenerated Java Package
       * name, if an entry is not already present
       *
       */
      public void map (String namespace) {
          if (namespaces.get(namespace) == null) {
            namespaces.put(namespace, Utils.makePackageName(namespace));
          }
      }
  
      /**
       * Invoke this method to associate a namespace URI with a particular Java Package
       */
      public void map (String namespace, String pkg) {
          namespaces.put(namespace, pkg);
      }
  
      public void setNamespaceMap(HashMap map) {
          namespaces.putAll(map);
      }
  
      /**
       * Get the Package name for the specified namespace
       */
      public String getPackage(String namespace) {
          return (String) namespaces.getCreate(namespace);
      }
  
      /**
       * Get the Package name for the specified QName
       */
      public String getPackage(QName qName) {
          return getPackage(qName.getNamespaceURI());
      }
  
      /**
       * Dump the contents of the symbol table.  For debugging purposes only.
       */
      public void dump(java.io.PrintStream out) {
          out.println();
          out.println(JavaUtils.getMessage("symbolTable00"));
          out.println("-----------------------");
          Iterator it = symbolTable.values().iterator();
          while (it.hasNext()) {
              Vector v = (Vector) it.next();
              for (int i = 0; i < v.size(); ++i) {
                  out.println(
                          v.elementAt(i).getClass().getName());
                  out.println(v.elementAt(i));
              }
          }
          out.println("-----------------------");
      } // dump
  
  } // class SymbolTable
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Type.java
  
  Index: Type.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  
  import org.w3c.dom.Node;
  
  import javax.wsdl.QName;
  
  /**
   * This class represents a type that is supported by the WSDL2Java emitter.
   * A Type has a QName representing its XML name and a Java Name, which
   * is its full java name.  The Type may also have a Node, which locates
   * the definition of the emit type in the xml.
   * A Type object extends SymTabEntry and is built by the SymbolTable class for
   * each XML complexType, simpleType, or element (necessary for ref=) that is
   * defined or encountered.
   *
   * @author Rich Scheuerle  (scheu@us.ibm.com)
   */
  public class Type extends SymTabEntry {
  
      private Node    node;        // Element node
      private boolean shouldEmit;  // Indicates if this Type should have code emitted for it.
      private boolean isBaseType;  // Indicates if represented by a java primitive or util class
  
      /**
       * Create a Type object for an xml construct name that represents a base java type
       */
      protected Type(QName pqName) {
          super(pqName, Utils.getBaseJavaName(pqName));
          node = null;
          shouldEmit = false;
          isBaseType = true;
      }
         
      /**
       * Create a Type object for an xml construct that references another type.        
       * The Type corresponding to the ultimate reference type is passed as refType
       */  
      protected Type(QName pqName, Type refType, Node pNode) {
          super(pqName, refType.getJavaName());
          node = pNode;
          shouldEmit = false;
          isBaseType = (refType.getBaseType() != null);
      }
         
      /**
       * Create a Type object for an xml construct that is not a base java type
       */  
      protected Type(QName pqName, String pjName, Node pNode) {
          super(pqName, pjName);
          node  = pNode;
          shouldEmit  = (node != null);
          isBaseType = false;
      }
  
      /**
       * Query Java Mapping Name
       */
      public String getJavaName() {
          return name;
      }
  
      /**
       * Query Java Mapping Name
       */
      public Node getNode() {
          return node;
      }
  
      /**
       * Query whether a Node defining the type exists.
       */
      public boolean isDefined() {
          return (node != null);
      }
  
      /**
       * Query whether a Node should be emitted.
       */
      public boolean getShouldEmit() {
          return shouldEmit;
      }
  
      /**
       * Indicate whether a Node should be emitted.
       */
      public void setShouldEmit(boolean pShouldEmit) {
          shouldEmit = pShouldEmit;
      }
  
      /**
       * Returns the Java Base Type Name.
       * For example if the Type represents a schema integer, "int" is returned.
       * If this is a user defined type, null is returned.
       */
      public String getBaseType() {
          if (isBaseType) {
              return name;
          }
          else {
              return null;
          }
      }
  
      /**
       * Get string representation.
       */
      public String toString() {
          return super.toString() + 
              "Emit?: " + shouldEmit + "\n" + 
              "Base?: " + isBaseType + "\n" + 
              "Node:  " + getNode() + "\n";
      }
  };
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  import org.w3c.dom.NamedNodeMap;
  
  import javax.wsdl.QName;
  import javax.wsdl.Fault;
  import javax.wsdl.Message;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.HashSet;
  import java.util.StringTokenizer;
  import java.util.Vector;
  
  import org.apache.axis.utils.JavaUtils;
  
  
  /**
   * This class contains static utility methods for the emitter.
   *
   * @author Rich Scheuerle  (scheu@us.ibm.com)
   * @author Tom Jordahl (tomj@macromedia.com)
   */
  public class Utils {
  
      /**
       * Capitalize the first character of the name.
       */
      public static String capitalizeFirstChar(String name) {
          char start = name.charAt(0);
  
          if (Character.isLowerCase(start)) {
              start = Character.toUpperCase(start);
              return start + name.substring(1);
          }
          return name;
      } // capitalizeFirstChar
  
      /**
       * Some QNames represent base types.  This routine returns the 
       * name of the base java type or null.
       * (These mappings based on JSR-101 version 0.5)
       */
      public static String getBaseJavaName(QName qName) {
          String localName = qName.getLocalPart();
          if (Utils.isSchemaNS(qName.getNamespaceURI())) {
              if (localName.equals("string")) {
                  return "java.lang.String";
              } else if (localName.equals("integer")) {
                  return "java.math.BigInteger";
              } else if (localName.equals("int")) {
                  return "int";
              } else if (localName.equals("long")) {
                  return "long";
              } else if (localName.equals("short")) {
                  return "short";
              } else if (localName.equals("decimal")) {
                  return "java.math.BigDecimal";
              } else if (localName.equals("float")) {
                  return "float";
              } else if (localName.equals("double")) {
                  return "double";
              } else if (localName.equals("boolean")) {
                  return "boolean";
              } else if (localName.equals("byte")) {
                  return "byte";
              } else if (localName.equals("QName")) {
                  return "javax.xml.rpc.namespace.QName";
              } else if (localName.equals("dateTime")) {
                  return "java.util.Date";
              } else if (localName.equals("base64Binary")) {
                  return "byte[]";
              } else if (localName.equals("hexBinary")) {
                  return "byte[]";
              } else if (localName.equals("date")) {   // Not defined in JSR-101
                  return "java.util.Date";
              } else if (localName.equals("void")) {   // Not defined in JSR-101
                  return "void";
              }
          }
          else if (Utils.isSoapEncodingNS(qName.getNamespaceURI())) {
              if (localName.equals("string")) {
                  return "java.lang.String";
              } else if (localName.equals("int")) {
                  return "int";
              } else if (localName.equals("short")) {
                  return "short";
              } else if (localName.equals("decimal")) {
                  return "java.math.BigDecimal";
              } else if (localName.equals("float")) {
                  return "float";
              } else if (localName.equals("double")) {
                  return "double";
              } else if (localName.equals("boolean")) {
                  return "boolean";
              } else if (localName.equals("base64")) {
                  return "byte[]";
              } else if (localName.equals("Array")) {    // Support for JAX-RPC Array
                  return "Object[]";
              } else if (localName.equals("Vector")) {   // Not defined in JSR-101
                  return "java.util.Vector";
              }
          }
          // special "java" namesapce means straight java types
          // So "java:void" maps to "void"
          else if (qName.getNamespaceURI().equals("java")) {  // Not defined in JSR-101
              return localName;
          }
          return null;
      }
  
  
      /**
       * Given a node, return the value of the given attribute.
       * If the attribute does not exist, searching continues through ancestor nodes until found.
       * This method is useful for finding attributes that pertain to a group of contained
       * nodes (i.e. xlmns, xmlns:tns, targetNamespace, name)
       */
      public static String getScopedAttribute(Node node, String attr) {
          if (node == null) {
              return null;
          }
  
          if (node.getAttributes() == null)
              return getScopedAttribute(node.getParentNode(), attr);
  
          Node attrNode = node.getAttributes().getNamedItem(attr);
          if (attrNode != null) {
              return attrNode.getNodeValue();
          }
          else {
              return getScopedAttribute(node.getParentNode(), attr);
          }
      }
  
      /**
       * Given a node, return the value of the given attribute.
       * Returns null if the attribute is not found
       */
      public static String getAttribute(Node node, String attr) {
          if (node == null || node.getAttributes() == null) {
              return null;
          }
  
          Node attrNode = node.getAttributes().getNamedItem(attr);
          if (attrNode != null) {
              return attrNode.getNodeValue();
          }
          else {
              return null;
          }
      }
  
      /**
       * Given a node, return the attributes that have the specified local name.
       * Returns null if the attribute is not found
       */
      public static Vector getAttributesWithLocalName(Node node, String localName) {
          Vector v = new Vector();
          if (node == null) {
              return v;
          }
  
          NamedNodeMap map = node.getAttributes();
          if (map != null) {
              for (int i=0; i < map.getLength(); i++) {
                  Node attrNode =  map.item(i);
                  if (attrNode != null &&
                      attrNode.getLocalName().equals(localName)) {
                      v.add(attrNode);
                  }
              }
          }
          return v;    
      }
  
      /**
       * An xml element may have a name.
       * For example &lt.element name="foo" type="b:bar"&gt.
       * has the name "element".  This routine gets the full QName of the element.
       */
      public static QName getNodeQName(Node node) {
          if (node == null) {
              return null;
          }
  
          String localName = node.getLocalName();
          if (localName == null) {
              return null;
          }
          String namespace = node.getNamespaceURI();
  
          return (new QName(namespace, localName));
      }
  
      /**
       * XML nodes may have a name attribute.
       * For example &lt.element name="foo" type="b:bar"&gt.
       * has the name attribute value "foo".  This routine gets the QName of the name attribute value.
       */
      public static QName getNodeNameQName(Node node) {
          if (node == null) {
              return null;
          }
          String localName = null;
          String namespace = null;
  
          // First try to get the name directly
          localName = getAttribute(node, "name");
          
          // If this fails and the node has a ref, use the ref name.
          if (localName == null) {
              QName ref = getNodeTypeRefQName(node, "ref");
              if (ref != null) {
                  localName = ref.getLocalPart();
                  namespace = ref.getNamespaceURI();
              }
          }
          
          // This routine may be called for complexType elements.  In some cases,
          // the complexType may be anonymous, which is why the getScopedAttribute
          // method is used.
          if (localName == null) {
              localName = getScopedAttribute(node, "name");
          }
          if (localName == null)
              return null;
  
          // Build and return the QName
          if (namespace == null) {
              namespace = getScopedAttribute(node, "targetNamespace");
          }
          return (new QName(namespace, localName));
      }
  
      /**
       * XML nodes may have a type/ref attribute.
       * For example &lt.element name="foo" type="b:bar"&gt.
       * has the type attribute value "b:bar". 
       * This routine gets the QName of the type/ref attribute value.
       *
       * Note: If the "minOccurs" and "maxOccurs" are set such that the 
       * type is a collection of "types", then an artificial qname is
       * returned to represent the collection.
       * 
       * If you want the QName for just the "type" without analyzing 
       * minOccurs/maxOccurs then use:
       *    getNodeTypeRefQName(node, "type")
       */
      public static QName getNodeTypeRefQName(Node node) {
          if (node == null) return null;
  
          QName qName= getNodeTypeRefQName(node, "type");
  
          // If the node has "type" and "maxOccurs" then the type is really
          // a collection.  There is qname in the wsdl which we can use to represent
          // the collection, so we need to invent one.
          // The local part of the qname is changed to <local>[minOccurs, maxOccurs]
          if (qName != null) {
              String maxOccursValue = getAttribute(node, "maxOccurs");
              String minOccursValue = getAttribute(node, "minOccurs");
              if (maxOccursValue == null) {
                  maxOccursValue = "1";
              }
              if (minOccursValue == null) {
                  minOccursValue = "1";
              }
              if (!maxOccursValue.equals("1") || !minOccursValue.equals("1")) {
                  String localPart = qName.getLocalPart();
                  localPart += "[" + minOccursValue + "," + maxOccursValue + "]";
                  qName.setLocalPart(localPart);
              }
          }
  
          if (qName == null) {
              qName = getNodeTypeRefQName(node, "ref");
          }
          // A WSDL Part uses the element attribute instead of the ref attribute
          if (qName == null) {
              qName = getNodeTypeRefQName(node, "element");
          }
          return qName;
      }
  
      /**
       * Obtain the QName of the type/ref using the indicated attribute name.
       * For example, the "type" attribute in an XML enumeration struct is the 
       * "base" attribute.  
       */
      public static QName getNodeTypeRefQName(Node node, String typeAttrName) {
          if (node == null) {
              return null;
          }
          String prefixedName = getAttribute(node, typeAttrName);
          if (prefixedName == null) {
              return null;
          }
          return getQNameFromPrefixedName(node,prefixedName);
      }
  
      /**
       * Convert a prefixed name into a qname
       */
      public static QName getQNameFromPrefixedName(Node node, String prefixedName) {
   
          String localName = prefixedName.substring(prefixedName.lastIndexOf(":")+1);
          String namespace = null;
          // Associate the namespace prefix with a namespace
          if (prefixedName.length() == localName.length()) {
             namespace = getScopedAttribute(node, "xmlns");  // Get namespace for unqualified reference
          }
          else {
             namespace = getScopedAttribute(node, "xmlns:" + prefixedName.substring(0, prefixedName.lastIndexOf(":")));
          }
          return (new QName(namespace, localName));
      }
  
  
      /**
       * Return true if the indicated string is the schema namespace
       */
    public static boolean isSchemaNS(String s) {
      return (s.equals("http://www.w3.org/2001/XMLSchema")
              || s.equals("http://www.w3.org/1999/XMLSchema")
              || s.equals("http://www.w3.org/2001/XMLSchema/")
              || s.equals("http://www.w3.org/1999/XMLSchema/"));
    }
  
      /**
       * Return true if the indicated string is the schema namespace
       */
      public static boolean isWsdlNS(String s) {
          return (s.equals("http://schemas.xmlsoap.org/wsdl/"));
      }
  
      /**
       * Return true if the indicated string is the soap wsdl namespace
       */
      public static boolean isSoapWsdlNS(String s) {
          return (s.equals("http://schemas.xmlsoap.org/wsdl/soap/"));
      }
  
      /**
       * Return true if the indicated string is the soap namespace
       */
      public static boolean isSoapNS(String s) {
          return (s.equals("http://schemas.xmlsoap.org/soap") ||
                  s.equals("http://schemas.xmlsoap.org/soap/") ||
                  s.equals("http://www.w3.org/2001/06/soap"));
      }
  
      /**
       * Return true if the indicated string is the soap encoding namespace
       */
      public static boolean isSoapEncodingNS(String s) {
          return (s.equals("http://schemas.xmlsoap.org/soap/encoding") ||
                  s.equals("http://schemas.xmlsoap.org/soap/encoding/") ||
                  s.equals("http://www.w3.org/2001/06/soap-encoding"));
      }
  
      /**
       * Map an XML name to a valid Java identifier
       */
      public static String xmlNameToJava(String name)
      {
          char[] nameArray = name.toCharArray();
          int len = name.length();
          StringBuffer result = new StringBuffer(len);
          
          // First character, lower case
          int i = 0;
          while (i < name.length() 
                  && !Character.isLetter(nameArray[i])) {
              i++;
          }
          result.append( Character.toLowerCase(nameArray[i]) );
          
          // The rest of the string
          boolean wordStart = false;
          for(int j = i + 1; j < len; ++j) {
              char c = nameArray[j];
  
              // if this is a bad char, skip it a remember to capitolize next
              // good character we encounter
              if( !Character.isLetterOrDigit(c)) {
                  wordStart = true;
                  continue;
              }
              result.append( wordStart ? Character.toUpperCase(c) : c );
              wordStart = false;
          }
          
          // covert back to a String
          String newName = result.toString();
          
          // check for Java keywords
          if (JavaUtils.isJavaKeyword(newName))
              newName = JavaUtils.makeNonJavaKeyword(newName);
          
          return newName;
      }
  
      /**
       * Map an XML name to a valid Java identifier w/ capitolized first letter 
       */ 
      public static String xmlNameToJavaClass(String name)
      {
          return capitalizeFirstChar(xmlNameToJava(name));
      }
  
      public static String makePackageName(String namespace)
      {
          String hostname = null;
  
          // get the target namespace of the document
          try {
              hostname = new URL(namespace).getHost();
          }
          catch (MalformedURLException e) {
              if (namespace.indexOf(":") > -1) {
                  hostname = namespace.substring(namespace.indexOf(":") + 1);
                  if (hostname.indexOf("/") > -1)
                      hostname = hostname.substring(0, hostname.indexOf("/") );
              }
              else {
                  hostname = namespace;
              }
          }
  
          // if we didn't file a hostname, bail
          if (hostname == null) {
              return null;
          }
  
          //convert illegal java identifier
          hostname = hostname.replace('-', '_');
  
          // tokenize the hostname and reverse it
          StringTokenizer st = new StringTokenizer( hostname, "." );
          String[] words = new String[ st.countTokens() ];
          for(int i = 0; i < words.length; ++i)
              words[i] = st.nextToken();
  
          StringBuffer sb = new StringBuffer(80);
          for(int i = words.length-1; i >= 0; --i) {
              String word = words[i];
              if (JavaUtils.isJavaKeyword(word)) {
                  word = JavaUtils.makeNonJavaKeyword(word);
              }
              // seperate with dot
              if( i != words.length-1 )
                  sb.append('.');
  
              // convert digits to underscores
              if( Character.isDigit(word.charAt(0)) )
                  sb.append('_');
              sb.append( word );
          }
          return sb.toString();
      }
  
      /**
       * Given a type, return the Java mapping of that type's holder.
       */
      public static String holder(Type type) {
          String typeValue = type.getName();
          if (typeValue.equals("java.lang.String")) {
              return "javax.xml.rpc.holders.StringHolder";
          }
          else if (typeValue.equals("java.math.BigDecimal")) {
              return "javax.xml.rpc.holders.BigDecimalHolder";
          }
          else if (typeValue.equals("java.math.BigInteger")) {
              return "javax.xml.rpc.holders.BigIntegerHolder";
          }
          else if (typeValue.equals("java.util.Date")) {
              return "javax.xml.rpc.holders.DateHolder";
          }
          else if (typeValue.equals("javax.xml.rpc.namespace.QName")) {
              return "javax.xml.rpc.holders.QNameHolder";
          }
          else if (typeValue.equals("byte[]")) {
              return "javax.xml.rpc.holders.ByteArrayHolder";
          }
          else if (typeValue.equals("int")
                  || typeValue.equals("long")
                  || typeValue.equals("short")
                  || typeValue.equals("float")
                  || typeValue.equals("double")
                  || typeValue.equals("boolean")
                  || typeValue.equals("byte"))
              return "javax.xml.rpc.holders." + capitalizeFirstChar(typeValue) + "Holder";
          else
              return typeValue + "Holder";
      } // holder
  
      /**
       * Given a fault, return the Java class name of the exception to be
       * generated from this fault
       * 
       * @param fault - The WSDL fault object
       * @return A Java class name for the fault
       */ 
      public static String getExceptionName(Fault fault) {
          /**
           * Use the message name as the fault class name,
           * fall back to fault name if there isn't a message part
           * 
           * NOTE: JAX-RPC version 0.5 says to use the message name, but
           * hopefully this will change to use the fault name, which makes
           * a good deal more sense (tomj@macromedia.com)
           */ 
          Message faultMessage = fault.getMessage();
          String exceptionName;
          if (faultMessage != null) {
              String faultMessageName = faultMessage.getQName().getLocalPart();
              exceptionName = Utils.xmlNameToJavaClass(faultMessageName);
          } else {
              exceptionName = Utils.xmlNameToJavaClass(fault.getName());
          }
          return exceptionName;
      }
  
  
      /**
       * This method returns a set of all the nested types.
       * Nested types are types declared within this Type (or descendents)
       * plus any extended types and the extended type nested types
       * The elements of the returned HashSet are Types.
       */
      public static HashSet getNestedTypes(Node type, SymbolTable symbolTable) {
          HashSet types = new HashSet();
          getNestedTypes(type, types, symbolTable);
          return types;
      } // getNestedTypes
  
      private static void getNestedTypes(
              Node type, HashSet types,SymbolTable symbolTable) {
          // Process types declared in this type
          Vector v = SchemaUtils.getComplexElementTypesAndNames(type, symbolTable);
          if (v != null) {
              for (int i = 0; i < v.size(); i+=2) {
                  if (!types.contains(v.get(i))) {
                      types.add(v.get(i));
                      getNestedTypes(
                              ((Type) v.get(i)).getNode(), types, symbolTable);
                  }
              }
          }
          // Process extended types
          Type extendType = SchemaUtils.getComplexElementExtensionBase(type, symbolTable);
          if (extendType != null) {
              if (!types.contains(extendType)) {
                  types.add(extendType);
                  getNestedTypes(extendType.getNode(), types, symbolTable);
              }
          }
  
          // Process array element types
          QName elementQName = SchemaUtils.getArrayElementQName(type);
          Type elementType = symbolTable.getTypeEntry(elementQName);
          if (elementType != null) {
              if (!types.contains(elementType)) {
                  types.add(elementType);
                  getNestedTypes(elementType.getNode(), types, symbolTable);
              }
          }
          
          
  
      } // getNestedTypes
  
      /**
       * Query Java Local Name
       */
      public static String getJavaLocalName(String fullName) {
          return fullName.substring(fullName.lastIndexOf('.') + 1);
      } // getJavaLocalName
  
      /**
       * Query Java Package Name
       */
      public static String getJavaPackageName(String fullName) {
          if (fullName.lastIndexOf('.') > 0) {
              return fullName.substring(0, fullName.lastIndexOf('.'));
          }
          else {
              return "";
          }
      } // getJavaPackageName
  
  }
  
  
  
  
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/Writer.java
  
  Index: Writer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.IOException;
  
  /**
  * This is the interface for all writers.  All writers, very simply, must
  * support a write method.
  *
  * Writer and WriterFactory are part of the Writer framework.  Folks who want
  * to use the emitter to generate stuff from WSDL should do 3 things:
  * 1.  Write implementations of the Writer interface, one each for PortType,
  *     Binding, Service, and Type.  These implementations generate the stuff
  *     for each of these WSDL types.
  * 2.  Write an implementation of the WriterFactory interface that returns
  *     instantiations of these Writer implementations as appropriate.
  * 3.  Implement a class with a main method (like Wsdl2java) that instantiates
  *     an Emitter and passes it the WriterFactory implementation
  */
  public interface Writer {
      /**
       * Write something.
       */
      public void write() throws IOException;
  }
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/wsdl/toJava/WriterFactory.java
  
  Index: WriterFactory.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.util.HashMap;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Definition;
  import javax.wsdl.Message;
  import javax.wsdl.PortType;
  import javax.wsdl.Service;
  
  /**
  * Writer and WriterFactory are part of the Writer framework.  Folks who want
  * to use the emitter to generate stuff from WSDL should do 3 things:
  * 1.  Write implementations of the Writer interface, one each for PortType,
  *     Binding, Service, and Type.  These implementations generate the stuff
  *     for each of these WSDL types.
  * 2.  Write an implementation of the WriterFactory interface that returns
  *     instantiations of these Writer implementations as appropriate.
  * 3.  Implement a class with a main method (like Wsdl2java) that instantiates
  *     an Emitter and passes it the WriterFactory implementation
  */
  
  public interface WriterFactory {
      /**
       * Allow the Writer extension to make a pass through the symbol table doing any pre-writing
       * logic, like creating the Java names for each object and constructing signature strings.
       */
      public void writerPass(Definition def, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate bindings for the given Message.
       */
      public Writer getWriter(Message message, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate bindings for the given PortType.
       */
      public Writer getWriter(PortType portType, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate bindings for the given Binding.
       */
      public Writer getWriter(Binding binding, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate bindings for the given Service.
       */
      public Writer getWriter(Service service, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate bindings for the given Type.
       */
      public Writer getWriter(Type type, SymbolTable symbolTable);
  
      /**
       * Get a Writer implementation that will generate anything that doesn't
       * fit into the scope of any of the other writers.
       */
      public Writer getWriter(Definition definition, SymbolTable symbolTable);
  
      /**
       * Provide the Emitter to the factory.
       */
      public void setEmitter(Emitter emitter);
  }
  
  
  
  1.9       +2 -2      xml-axis/java/test/wsdl/Wsdl2javaAntTask.java
  
  Index: Wsdl2javaAntTask.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Wsdl2javaAntTask.java	2001/12/06 13:11:53	1.8
  +++ Wsdl2javaAntTask.java	2001/12/11 15:08:48	1.9
  @@ -53,8 +53,8 @@
    */
   package test.wsdl;
   
  -import org.apache.axis.wsdl.Emitter;
  -import org.apache.axis.wsdl.JavaWriterFactory;
  +import org.apache.axis.wsdl.toJava.Emitter;
  +import org.apache.axis.wsdl.toJava.JavaWriterFactory;
   
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  
  
  
  1.5       +2 -2      xml-axis/java/test/wsdl/Wsdl2javaTestSuite.java
  
  Index: Wsdl2javaTestSuite.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Wsdl2javaTestSuite.java	2001/10/30 14:43:19	1.4
  +++ Wsdl2javaTestSuite.java	2001/12/11 15:08:48	1.5
  @@ -61,8 +61,8 @@
   import org.apache.axis.transport.http.SimpleAxisServer;
   import org.apache.axis.utils.AxisClassLoader;
   import org.apache.axis.utils.Options;
  -import org.apache.axis.wsdl.Emitter;
  -import org.apache.axis.wsdl.JavaWriterFactory;
  +import org.apache.axis.wsdl.toJava.Emitter;
  +import org.apache.axis.wsdl.toJava.JavaWriterFactory;
   import org.apache.tools.ant.BuildLogger;
   import org.apache.tools.ant.DefaultLogger;
   import org.apache.tools.ant.Location;
  
  
  

Mime
View raw message