You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2003/04/19 23:08:58 UTC

cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaBeanWriter.java

sandholm    2003/04/19 14:08:58

  Modified:    java/src/org/apache/axis/description Tag:
                        dynamic_deserialization_branch TypeDesc.java
               java/src/org/apache/axis/encoding Tag:
                        dynamic_deserialization_branch
                        DeserializationContextImpl.java
               java/src/org/apache/axis/encoding/ser Tag:
                        dynamic_deserialization_branch
                        ArrayDeserializer.java BeanDeserializer.java
                        SimpleDeserializer.java
               java/src/org/apache/axis/message Tag:
                        dynamic_deserialization_branch SOAPEnvelope.java
                        SOAPHeader.java
               java/src/org/apache/axis/providers/java Tag:
                        dynamic_deserialization_branch RPCProvider.java
               java/src/org/apache/axis/utils Tag:
                        dynamic_deserialization_branch XMLUtils.java
               java/src/org/apache/axis/wsdl/symbolTable Tag:
                        dynamic_deserialization_branch SchemaUtils.java
                        Utils.java
               java/src/org/apache/axis/wsdl/toJava Tag:
                        dynamic_deserialization_branch JavaBeanWriter.java
  Added:       java/src/org/apache/axis/encoding Tag:
                        dynamic_deserialization_branch AnyContentType.java
  Log:
  various patches to deserialization branch
  to be merged into trunk post 1.1
  -fixes to dynamic deserialization of beans
  -xsd:union support
  -SOAP Envelope dirty flag bug fix
  
  
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.27.2.1  +3 -0      xml-axis/java/src/org/apache/axis/description/TypeDesc.java
  
  Index: TypeDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/TypeDesc.java,v
  retrieving revision 1.27
  retrieving revision 1.27.2.1
  diff -u -r1.27 -r1.27.2.1
  --- TypeDesc.java	20 Feb 2003 22:43:52 -0000	1.27
  +++ TypeDesc.java	19 Apr 2003 21:08:56 -0000	1.27.2.1
  @@ -190,6 +190,9 @@
                       FieldDesc [] parentFields = superDesc.getFields(true);
   // START FIX http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17188
                       if (parentFields != null) {
  +		      if (fields == null) {
  +			  fields = new FieldDesc[0];
  +		      }
                         FieldDesc [] ret = new FieldDesc[parentFields.length + fields.length];
                         System.arraycopy(parentFields, 0, ret, 0, parentFields.length);
                         System.arraycopy(fields, 0, ret, parentFields.length, fields.length);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.74.2.2  +9 -0      xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
  
  Index: DeserializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
  retrieving revision 1.74.2.1
  retrieving revision 1.74.2.2
  diff -u -r1.74.2.1 -r1.74.2.2
  --- DeserializationContextImpl.java	26 Feb 2003 05:18:54 -0000	1.74.2.1
  +++ DeserializationContextImpl.java	19 Apr 2003 21:08:56 -0000	1.74.2.2
  @@ -480,6 +480,15 @@
           if (cls == null) {
               return null;
           }
  +        if (cls.isArray()) {
  +            cls = cls.getComponentType();
  +        }
  +        if (javax.xml.rpc.holders.Holder.class.isAssignableFrom(cls)) {
  +            try {
  +                cls = cls.getField("value").getType();
  +            } catch (Exception e) {
  +            }
  +        }
           Deserializer dser = null;
           try {
               Method method = cls.getMethod(DESERIALIZER_METHOD, DESERIALIZER_CLASSES);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +69 -0     xml-axis/java/src/org/apache/axis/encoding/Attic/AnyContentType.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.35.2.2  +0 -1      xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java
  
  Index: ArrayDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java,v
  retrieving revision 1.35.2.1
  retrieving revision 1.35.2.2
  diff -u -r1.35.2.1 -r1.35.2.2
  --- ArrayDeserializer.java	26 Feb 2003 05:18:54 -0000	1.35.2.1
  +++ ArrayDeserializer.java	19 Apr 2003 21:08:57 -0000	1.35.2.2
  @@ -301,7 +301,6 @@
           }
           if (arrayClass == null) {
               arrayClass = context.getDestinationClass();
  -            context.setDestinationClass(arrayClass.getComponentType());
           }
   
           if (arrayClass == null) {
  
  
  
  1.59.2.2  +5 -4      xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.59.2.1
  retrieving revision 1.59.2.2
  diff -u -r1.59.2.1 -r1.59.2.2
  --- BeanDeserializer.java	26 Feb 2003 05:18:54 -0000	1.59.2.1
  +++ BeanDeserializer.java	19 Apr 2003 21:08:57 -0000	1.59.2.2
  @@ -333,8 +333,8 @@
       public BeanPropertyDescriptor getAnyPropertyDesc() {
           if (typeDesc == null)
               return null;
  -
  -        return typeDesc.getAnyDesc();
  +        
  +       return typeDesc.getAnyDesc();
       }
   
       /**
  @@ -436,8 +436,8 @@
                                              String href,
                                              DeserializationContext context) {
           if (javaType.isArray()) {
  -            context.setDestinationClass(javaType.getComponentType());
  -        }
  +            context.setDestinationClass(javaType);
  +        } 
           // See if we have a cached deserializer
           if (cacheStringDSer != null) {
               if (String.class.equals(javaType) &&
  @@ -468,6 +468,7 @@
                   dSer = context.getDeserializer(javaType, defaultXMLType);
               } else {
                   dSer = new DeserializerImpl();
  +                context.setDestinationClass(javaType);
                   dSer.setDefaultType(defaultXMLType);
               }
           }
  
  
  
  1.31.2.2  +6 -1      xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java
  
  Index: SimpleDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleDeserializer.java,v
  retrieving revision 1.31.2.1
  retrieving revision 1.31.2.2
  diff -u -r1.31.2.1 -r1.31.2.2
  --- SimpleDeserializer.java	26 Feb 2003 05:18:54 -0000	1.31.2.1
  +++ SimpleDeserializer.java	19 Apr 2003 21:08:57 -0000	1.31.2.2
  @@ -278,7 +278,12 @@
               }
           }    
           if (constructor == null) {
  -            return null;
  +	    try {
  +                constructor = 
  +                    javaType.getDeclaredConstructor(new Class [] {String.class});
  +	    } catch (Exception e) {
  +                return null;
  +	    }
           }
           return constructor.newInstance(new Object [] { source });
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.85.2.1  +1 -0      xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.85
  retrieving revision 1.85.2.1
  diff -u -r1.85 -r1.85.2.1
  --- SOAPEnvelope.java	21 Jan 2003 17:01:13 -0000	1.85
  +++ SOAPEnvelope.java	19 Apr 2003 21:08:57 -0000	1.85.2.1
  @@ -448,6 +448,7 @@
       public javax.xml.soap.SOAPBody addBody() throws SOAPException {
           if (body == null) {
               body = new SOAPBody(this, soapConstants);
  +            _isDirty = true;
               return body;
           } else {
               throw new SOAPException(Messages.getMessage("bodyPresent"));
  
  
  
  1.66.2.1  +3 -1      xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
  
  Index: SOAPHeader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
  retrieving revision 1.66
  retrieving revision 1.66.2.1
  diff -u -r1.66 -r1.66.2.1
  --- SOAPHeader.java	24 Dec 2002 17:45:02 -0000	1.66
  +++ SOAPHeader.java	19 Apr 2003 21:08:57 -0000	1.66.2.1
  @@ -129,8 +129,10 @@
       public javax.xml.soap.SOAPHeaderElement addHeaderElement(Name name)
           throws SOAPException {
           SOAPHeaderElement headerElement = new SOAPHeaderElement(name);
  -        headerElement.setEnvelope(getEnvelope());
  +        SOAPEnvelope envelope = getEnvelope();
  +        headerElement.setEnvelope(envelope);
           addHeader(headerElement);
  +        envelope.setDirty(true);
           return headerElement;
       }
       
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.103.2.1 +3 -1      xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.103
  retrieving revision 1.103.2.1
  diff -u -r1.103 -r1.103.2.1
  --- RPCProvider.java	20 Jan 2003 18:08:01 -0000	1.103
  +++ RPCProvider.java	19 Apr 2003 21:08:57 -0000	1.103.2.1
  @@ -269,7 +269,9 @@
   
                   if (holderClass != null &&
                           Holder.class.isAssignableFrom(holderClass)) {
  -                    argValues[numArgs + i] = holderClass.newInstance();
  +                    if (argValues[numArgs + i] == null) { 
  +                        argValues[numArgs + i] = holderClass.newInstance();
  +		    }
                       // Store an RPCParam in the outs collection so we
                       // have an easy and consistent way to write these
                       // back to the client below
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.77.2.1  +25 -2     xml-axis/java/src/org/apache/axis/utils/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
  retrieving revision 1.77
  retrieving revision 1.77.2.1
  diff -u -r1.77 -r1.77.2.1
  --- XMLUtils.java	30 Dec 2002 06:34:48 -0000	1.77
  +++ XMLUtils.java	19 Apr 2003 21:08:57 -0000	1.77.2.1
  @@ -508,8 +508,13 @@
   
       public static String getNamespace(String prefix, Node e) {
           while (e != null && (e.getNodeType() == Node.ELEMENT_NODE)) {
  -            Attr attr =
  -                ((Element)e).getAttributeNodeNS(Constants.NS_URI_XMLNS, prefix);
  +            Attr attr = null;
  +            if (prefix == null) {
  +                attr = ((Element)e).getAttributeNode("xmlns");
  +            } else {
  +                attr = ((Element)e).getAttributeNodeNS(Constants.NS_URI_XMLNS, 
  +                                                       prefix);
  +            }
               if (attr != null) return attr.getValue();
               e = e.getParentNode();
           }
  @@ -523,6 +528,19 @@
        * @return a QName generated from the given string representation
        */
       public static QName getQNameFromString(String str, Node e) {
  +        return getQNameFromString(str, e, false);
  +    }
  +    /**
  +     * Return a QName when passed a string like "foo:bar" by mapping
  +     * the "foo" prefix to a namespace in the context of the given Node.
  +     * If default namespace is found it is returned as part of the QName.
  +     *
  +     * @return a QName generated from the given string representation
  +     */
  +    public static QName getFullQNameFromString(String str, Node e) {
  +        return getQNameFromString(str, e, true);
  +    }
  +    private static QName getQNameFromString(String str, Node e, boolean defaultNS) {
           if (str == null || e == null)
               return null;
   
  @@ -534,6 +552,11 @@
                   return null;
               return new QName(ns, str.substring(idx + 1));
           } else {
  +            if (defaultNS) {
  +                String ns = getNamespace(null, e);
  +                if (ns != null) 
  +                    return new QName(ns, str);
  +            }
               return new QName("", str);
           }
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.22.2.1  +37 -14    xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java
  
  Index: SchemaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java,v
  retrieving revision 1.22
  retrieving revision 1.22.2.1
  diff -u -r1.22 -r1.22.2.1
  --- SchemaUtils.java	3 Jan 2003 13:56:08 -0000	1.22
  +++ SchemaUtils.java	19 Apr 2003 21:08:58 -0000	1.22.2.1
  @@ -182,17 +182,26 @@
               return v;
           } else {
               // This may be a simpleType, return the type with the name "value"
  -            QName simpleQName = getSimpleTypeBase(node);
  +            QName[] simpleQName = getContainedSimpleTypes(node);
               if (simpleQName != null) {
  -                TypeEntry simpleType = symbolTable.getType(simpleQName);
  -                if (simpleType != null) {
  -                    Vector v = new Vector();
  -                    ElementDecl elem = new ElementDecl();
  -                    elem.setType(simpleType);
  -                    elem.setName(new javax.xml.namespace.QName("", "value"));
  -                    v.add(elem);
  -                    return v;
  -                }
  +                Vector v = null;
  +		for (int i = 0; i < simpleQName.length; i++) {    
  +                    TypeEntry simpleType = symbolTable.getType(simpleQName[i]);
  +                    if (simpleType != null) {
  +			if (v == null) {
  +			    v = new Vector();
  +		        }
  +                        ElementDecl elem = new ElementDecl();
  +                        elem.setType(simpleType);
  +			if (simpleQName.length > 1) {
  +                            elem.setName(new javax.xml.namespace.QName("", simpleQName[i].getLocalPart() + "Value"));
  +			} else {
  +                            elem.setName(new javax.xml.namespace.QName("", "value"));
  +			}
  +                        v.add(elem);
  +                    }
  +		}
  +                return v;
               }
           }
           return null;
  @@ -543,7 +552,14 @@
        * the QName of the simpleType base is returned.
        */
       public static QName getSimpleTypeBase(Node node) {
  -        QName baseQName = null;
  +	QName[] qname = getContainedSimpleTypes(node);
  +	if (qname != null && qname.length > 0) {
  +	    return qname[0];
  +        }
  +	return null;
  +    }
  +    public static QName[] getContainedSimpleTypes(Node node) {
  +        QName[] baseQNames = null;
   
           if (node == null) {
               return null;
  @@ -566,9 +582,12 @@
               // (There may be other #text nodes, which we will ignore).
               NodeList children = node.getChildNodes();
               Node restrictionNode = null;
  +            Node unionNode = null;
               for (int j = 0; j < children.getLength() && restrictionNode == null; j++) {
                   if (isXSDNode(children.item(j), "restriction")) {
                       restrictionNode = children.item(j);
  +                } else if (isXSDNode(children.item(j), "union")) {
  +                    unionNode = children.item(j);
                   }
               }
   
  @@ -576,11 +595,15 @@
               // (the base attribute contains this type).
               
               if (restrictionNode != null) {
  -                baseQName = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false);
  +		baseQNames = new QName[1];
  +                baseQNames[0] = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false);
  +            }
  +            if (unionNode != null) {
  +                baseQNames = Utils.getMemberTypeQNames(unionNode);
               }
               
               // Look for enumeration elements underneath the restriction node
  -            if (baseQName != null && restrictionNode != null) {
  +            if (baseQNames != null && restrictionNode != null && unionNode != null) {
                   NodeList enums = restrictionNode.getChildNodes();
                   for (int i=0; i < enums.getLength(); i++) {
                       if (isXSDNode(enums.item(i), "enumeration")) {
  @@ -591,7 +614,7 @@
                   }
               }
           }
  -        return baseQName;
  +        return baseQNames;
       }
   
       /**
  
  
  
  1.24.2.1  +16 -0     xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java,v
  retrieving revision 1.24
  retrieving revision 1.24.2.1
  diff -u -r1.24 -r1.24.2.1
  --- Utils.java	3 Jan 2003 13:56:08 -0000	1.24
  +++ Utils.java	19 Apr 2003 21:08:58 -0000	1.24.2.1
  @@ -56,6 +56,7 @@
   
   import org.apache.axis.Constants;
   import org.apache.axis.utils.JavaUtils;
  +import org.apache.axis.utils.XMLUtils;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
   
  @@ -66,6 +67,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Vector;
  +import java.util.StringTokenizer;
   
   /**
    * This class contains static utility methods for the emitter.
  @@ -358,6 +360,20 @@
               qName = getTypeQNameFromAttr(node, "base");
           }
           return qName;
  +    }
  +
  +    public static QName[] getMemberTypeQNames(Node node) {
  +        String attribute = getAttribute(node, "memberTypes");
  +	if (attribute == null) {
  +	    return null;
  +        }
  +	StringTokenizer tokenizer = new StringTokenizer(attribute, " ");
  +	QName[] memberTypes = new QName[tokenizer.countTokens()];
  +	for (int i = 0; tokenizer.hasMoreElements(); i++) {
  +	    String element = (String) tokenizer.nextElement(); 
  +	    memberTypes[i] = XMLUtils.getFullQNameFromString(element, node);
  +	}
  +	return memberTypes;
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.1  +109 -43   xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
  
  Index: JavaBeanWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
  retrieving revision 1.33
  retrieving revision 1.33.2.1
  diff -u -r1.33 -r1.33.2.1
  --- JavaBeanWriter.java	11 Dec 2002 22:38:30 -0000	1.33
  +++ JavaBeanWriter.java	19 Apr 2003 21:08:58 -0000	1.33.2.1
  @@ -66,6 +66,8 @@
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.util.Vector;
  +import java.util.ArrayList;
  +import java.util.Iterator;
   
   /**
    * This is Wsdl2java's Complex Type Writer.  It writes the <typeName>.java file.
  @@ -77,7 +79,7 @@
       private TypeEntry extendType;
       protected JavaBeanHelperWriter helper;
       protected Vector names = new Vector(); // even indices: types, odd: vars
  -    protected String simpleValueType = null;  // name of type of simple value
  +    protected ArrayList simpleValueTypes = new ArrayList();  // name of type of simple value
       protected PrintWriter pw;
   
       // The following fields can be set by extended classes
  @@ -91,6 +93,8 @@
       protected boolean enableEquals = true;
       protected boolean enableHashCode = true;
   
  +    protected boolean isAny = false;
  +
       /**
        * Constructor.
        * @param emitter
  @@ -128,8 +132,9 @@
   
           // Populate Names Vector with the names and types of the members.
           // The write methods use the names vector whenever they need to get
  -        // a member name or type.
  -        preprocess();
  +        // a member name or type. Moved to implements callback in order 
  +        // to set any interface
  +        // preprocess();
   
           // Write Member Fields
           writeMemberFields();
  @@ -193,6 +198,7 @@
                   if (elem.getAnyElement()) {
                       typeName = "org.apache.axis.message.MessageElement []";
                       variableName = Constants.ANYCONTENT;
  +                    isAny = true;
                   } else {
                       String elemName = elem.getName().getLocalPart();
                       variableName = Utils.xmlNameToJava(elemName);
  @@ -200,8 +206,8 @@
                   names.add(typeName);
                   names.add(variableName);
                   if (type.isSimpleType() &&
  -                    variableName.equals("value")) {
  -                    simpleValueType = typeName;
  +                    (variableName.endsWith("Value") || variableName.equals("value"))) {
  +                    simpleValueTypes.add(typeName);
                   }
               }
           }
  @@ -215,8 +221,8 @@
                   names.add(typeName);
                   names.add(variableName);
                   if (type.isSimpleType() &&
  -                    variableName.equals("value")) {
  -                    simpleValueType = typeName;
  +                    (variableName.endsWith("Value") || variableName.equals("value"))) {
  +                    simpleValueTypes.add(typeName);
                   }
               }
           }
  @@ -259,6 +265,13 @@
           if (type.isSimpleType()) {
               implementsText += ", org.apache.axis.encoding.SimpleType";
           }
  +        
  +        // need to call this to find out whether the type contains any elements
  +        preprocess();
  +        
  +        if (isAny) {
  +            implementsText += ", org.apache.axis.encoding.AnyContentType";
  +        };
           implementsText += " ";
           return implementsText;
       }
  @@ -268,6 +281,9 @@
        */
       protected void writeMemberFields() {
           // Define the member element of the bean
  +	if (simpleValueTypes.size() > 1) {
  +            pw.println("    private java.lang.String value;");
  +	}
           for (int i = 0; i < names.size(); i += 2) {
               String typeName = (String) names.get(i);
               String variable = (String) names.get(i + 1);
  @@ -302,6 +318,9 @@
        * constructor.
        */
       protected void writeFullConstructor() {
  +	if (type.isSimpleType()) {
  +            return;
  +	}
           // The constructor needs to consider all extended types
           Vector extendList = new Vector();
           extendList.add(type);
  @@ -397,62 +416,78 @@
       protected void writeSimpleConstructors() {
           // If this is a simple type,need to emit a string
           // constructor and a value construtor.
  -        if (type.isSimpleType() && simpleValueType != null) {
  -            if (!simpleValueType.equals("java.lang.String")) {
  -                pw.println("    public " + className + "(" +
  -                           simpleValueType + " value) {");
  -                pw.println("        this.value = value;");
  -                pw.println("    }");
  +        if (simpleValueTypes.size() == 0) {
  +	    return;
  +	}
  +        pw.println("    // " + Messages.getMessage("needStringCtor"));
  +        if (simpleValueTypes.size() > 1 || simpleValueTypes.get(0).equals("java.lang.String")) {
  +            pw.println("    public " + className + "(java.lang.String value) {");
  +            pw.println("        this.value = value;");
  +	    pw.println("    }");
  +            for (Iterator iterator = simpleValueTypes.iterator();
  +                 iterator.hasNext();) {
  +                String typeName = (String) iterator.next();
  +                if (typeName.equals("java.lang.String")) {
  +                    continue;
  +                }
  +                pw.println("    public " + className + "(" + typeName + " value) {");
  +                pw.println("        setValue(value);");
  +	        pw.println("    }");
                   pw.println();
               }
  -
  -            pw.println("    // " + Messages.getMessage("needStringCtor"));
  +	} else if (simpleValueTypes.size() == 1) {
  +            pw.println("    public " + className + "(" + simpleValueTypes.get(0) + " value) {");
  +            pw.println("        this.value = value;");
  +	    pw.println("    }");
               pw.println("    public " + className + "(java.lang.String value) {");
  +	    writeSimpleTypeGetter((String)simpleValueTypes.get(0), null, "this.value =");
  +	    pw.println("    }");
  +            pw.println();
  +	}
  +    }
  +    protected void writeSimpleTypeGetter(String simpleValueType, String name, String returnString) {
               // Make sure we wrap base types with its Object type
  +            if (name != null) {
  +                pw.println("        if (this." + name + " != null) {");
  +                pw.println("            " + returnString + " this." + name + ";");
  +                pw.println("        }");
  +            }
               String wrapper = JavaUtils.getWrapper(simpleValueType);
   
               if (wrapper != null) {
  -                pw.println("        this.value = new " + wrapper +
  +                pw.println("        " + returnString + " new " + wrapper +
                              "(value)." + simpleValueType + "Value();");
               } else {
                   if (simpleValueType.equals("byte[]")) {
  -                    pw.println("        this.value = org.apache.axis.types.HexBinary.decode(value);");
  +                    pw.println("        " + returnString + " org.apache.axis.types.HexBinary.decode(value);");
                   }
                   else if (simpleValueType.equals("org.apache.axis.types.URI")) {
                       pw.println("        try {");
  -                    pw.println("            this.value = new org.apache.axis.types.URI(value);");
  +                    pw.println("            " + returnString + " new org.apache.axis.types.URI(value);");
                       pw.println("        }");
                       pw.println("        catch (org.apache.axis.types.URI.MalformedURIException mue) {");
  -                    pw.println("            this.value = new org.apache.axis.types.URI();");
  +                    pw.println("            " + returnString + " new org.apache.axis.types.URI();");
                       pw.println("       }");
                   } 
                   else if (simpleValueType.equals("java.util.Date")) {
                     pw.println("        try {");
  -                  pw.println("            this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);");
  +                  pw.println("            " + returnString + " (java.text.DateFormat.getDateTimeInstance()).parse(value);");
                     pw.println("        }");
                     pw.println("        catch (java.text.ParseException e){");
                     pw.println("            throw new java.lang.RuntimeException(e.toString());");
                     pw.println("        }");
                   }
                   else if (simpleValueType.equals("java.util.Calendar")) {
  -                  pw.println("        java.util.Calendar cal = java.util.Calendar.getInstance();"); 
  -                  pw.println("        try {");
  -                  pw.println("          java.util.Date dt = (java.text.DateFormat.getDateTimeInstance()).parse(value);");
  -                  pw.println("          cal.setTime(dt);");
  -                  pw.println("          this.value = cal;");
  -                  pw.println("        }");
  -                  pw.println("        catch (java.text.ParseException e){");
  -                  pw.println("            throw new java.lang.RuntimeException(e.toString());");
  -                  pw.println("        }");
  +                  pw.println("        java.util.Calendar cal =");
  +                  pw.println("            (java.util.Calendar) new org.apache.axis.encoding.ser.CalendarDeserializer(");
  +		  pw.println("                java.lang.String.class, org.apache.axis.Constants.XSD_STRING).makeValue(value);");
  +                  pw.println("        " + returnString + " cal;");
                   }                
                   else {
  -                    pw.println("        this.value = new " +
  +                    pw.println("        " + returnString + " new " +
                                  simpleValueType + "(value);");
                   }
               }
  -            pw.println("    }");
  -            pw.println();
  -        }
       }
   
       /**
  @@ -462,21 +497,41 @@
        */
       protected void writeToStringMethod() {
           // If this is a simple type, emit a toString
  -        if (type.isSimpleType() && simpleValueType != null) {
  -            pw.println("    // " + Messages.getMessage("needToString"));
  -            String wrapper = JavaUtils.getWrapper(simpleValueType);
  -            pw.println("    public java.lang.String toString() {");
  +        if (simpleValueTypes.size() == 0) {
  +	    return;
  +	}
  +        pw.println("    // " + Messages.getMessage("needToString"));
  +        pw.println("    public java.lang.String toString() {");
  +        if (simpleValueTypes.size() > 1 || simpleValueTypes.get(0).equals("java.lang.String")) {
  +            pw.println("        return value;");
  +	} else {
  +            String wrapper = JavaUtils.getWrapper((String)simpleValueTypes.get(0));
               if (wrapper != null) {
                   pw.println("        return new " + wrapper + "(value).toString();");
               } else {
  -                if(simpleValueType.equals("byte[]")) {
  +                if(simpleValueTypes.get(0).equals("byte[]")) {
                       pw.println("        return value == null ? null : org.apache.axis.types.HexBinary.encode(value);" );
                   } else {              
                       pw.println("        return value == null ? null : value.toString();");
                   }
               }
  -            pw.println("    }");
  -            pw.println();
  +	}
  +        pw.println("    }");
  +        pw.println();
  +    }
  +
  +    protected void writeSimpleTypeSetter(String simpleValueType) {
  +        String wrapper = JavaUtils.getWrapper(simpleValueType);
  +        if (wrapper != null) {
  +            pw.println("        this.value = new " + wrapper + "(value).toString();");
  +        } else {
  +            if(simpleValueType.equals("byte[]")) {
  +                pw.println("        this.value = value == null ? null : org.apache.axis.types.HexBinary.encode(value);" );
  +	    } else if(simpleValueType.equals("java.util.Calendar")) {
  +                pw.println("        this.value = value == null ? null : new org.apache.axis.encoding.ser.CalendarSerializer().getValueAsString(value, null);");
  +            } else {              
  +                pw.println("        this.value = value == null ? null : value.toString();");
  +            }
           }
       }
   
  @@ -498,14 +553,25 @@
               if (enableGetters) {
                   pw.println("    public " + typeName + " " +
                              get + capName + "() {");
  -                pw.println("        return " + name + ";");
  +                if (simpleValueTypes.size() > 1) {
  +			writeSimpleTypeGetter(typeName, name, "return");
  +		} else {
  +		    pw.println("        return " + name + ";");
  +		}
                   pw.println("    }");
                   pw.println();
               }
               if (enableSetters) {
  -                pw.println("    public void set" + capName + "(" +
  +                if (simpleValueTypes.size() > 1) {
  +                    pw.println("    public void setValue(" +
  +                           typeName + " value) {");
  +		    writeSimpleTypeSetter(typeName);
  +                    pw.println("        this." + name + " = value;");
  +		} else {
  +                    pw.println("    public void set" + capName + "(" +
                              typeName + " " + name + ") {");
  -                pw.println("        this." + name + " = " + name + ";");
  +                    pw.println("        this." + name + " = " + name + ";");
  +		}
                   pw.println("    }");
                   pw.println();
               }