ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject svn commit: r391340 [2/3] - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws: ./ cpp/ cpp/literal/
Date Tue, 04 Apr 2006 15:36:00 GMT
Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java?rev=391340&r1=391339&r2=391340&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java (original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java Tue Apr  4 08:35:58 2006
@@ -22,13 +22,16 @@
 
 package org.apache.axis.wsdl.wsdl2ws.cpp;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
 
+import javax.xml.namespace.QName;
+
+import org.apache.axis.wsdl.symbolTable.BaseType;
 import org.apache.axis.wsdl.wsdl2ws.CUtils;
 import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
-import org.apache.axis.wsdl.wsdl2ws.info.ElementInfo;
 import org.apache.axis.wsdl.wsdl2ws.info.Type;
 import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
 
@@ -40,756 +43,1110 @@
 
 public class BeanParamWriter extends ParamCPPFileWriter 
 {
-	public BeanParamWriter(WebServiceContext wscontext, Type type) throws WrapperFault 
+    public BeanParamWriter(WebServiceContext wscontext, Type type)
+            throws WrapperFault
     {
-		super(wscontext, type);
-	}
+        super(wscontext, type);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.axis.wsdl.wsdl2ws.cpp.ParamCPPFileWriter#writeGlobalCodes()
-	 */
-	protected void writeGlobalCodes() throws WrapperFault 
-    {
-		try 
-        {
-			HashSet typeSet = new HashSet();
-			String typeName;
-			for (int i = 0; i < attribs.length; i++) 
-            {
-				if (!attribs[i].isSimpleType()) 
-                {
-					typeSet.add(attribs[i].getTypeName());
-				}
-			}
-			Iterator itr = typeSet.iterator();
-			while (itr.hasNext()) 
-            {
-				/*
-				 * Needed for self referenced array. <xsd:complexType
-				 * name="Type1"> <xsd:sequence> <xsd:element name="followings"
-				 * maxOccurs="unbounded" minOccurs="0" type="tns:Type1" />
-				 * <xsd:element name="kind" type="xsd:string" /> <xsd:element
-				 * name="index" type="xsd:int" /> </xsd:sequence> <xsd:attribute
-				 * name="att_kind" type="tns:Kind" /> </xsd:complexType>
-				 */
-				typeName = itr.next().toString();
-				if (!typeName.equals(type.getName().getLocalPart())) 
-                {
-					writer.write("extern int Axis_DeSerialize_" + typeName
-							+ "(" + typeName
-							+ "* param, IWrapperSoapDeSerializer* pDZ);\n");
-					writer.write("extern void* Axis_Create_" + typeName + "("
-							+ typeName
-							+ "* pObj, bool bArray = false, int nSize=0);\n");
-					writer.write("extern void Axis_Delete_" + typeName + "("
-							+ typeName
-							+ "* param, bool bArray = false, int nSize=0);\n");
-					writer
-							.write("extern int Axis_Serialize_"
-									+ typeName
-									+ "("
-									+ typeName
-									+ "* param, IWrapperSoapSerializer* pSZ, bool bArray = false);\n");
-					writer.write("extern int Axis_GetSize_" + typeName
-							+ "();\n\n");
-				} 
-                else 
-                {
-					writer.write("int Axis_DeSerialize_" + typeName + "("
-							+ typeName
-							+ "* param, IWrapperSoapDeSerializer* pDZ);\n");
-					writer.write("void* Axis_Create_" + typeName + "("
-							+ typeName + "* pObj, bool bArray, int nSize);\n");
-					writer.write("void Axis_Delete_" + typeName + "("
-							+ typeName + "* param, bool bArray, int nSize);\n");
-					writer
-							.write("int Axis_Serialize_"
-									+ typeName
-									+ "("
-									+ typeName
-									+ "* param, IWrapperSoapSerializer* pSZ, bool bArray);\n");
-					writer.write("int Axis_GetSize_" + typeName + "();\n\n");
-				}
-			}
-
-			writeGetSetMethods();
-			writeSerializeGlobalMethod();
-			writeDeSerializeGlobalMethod();
-			writeCreateGlobalMethod();
-			writeDeleteGlobalMethod();
-			writeGetSizeGlobalMethod();
-		} 
-        catch (IOException e) 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.axis.wsdl.wsdl2ws.cpp.ParamCPPFileWriter#writeGlobalCodes()
+     */
+    protected void writeGlobalCodes() throws WrapperFault
+    {
+        try
         {
-			throw new WrapperFault(e);
-		}
-	}
-
-	/**
-	 * Dushshantha: following method writes getters and setters for the
-	 * attributes
-	 */
-
-	private void writeGetSetMethods() throws WrapperFault 
-    {
-		/**
-		 * Dushshantha: writing getter
-		 */
+            HashSet typeSet = new HashSet();
+            String typeName;
+            
+            for (int i = 0; i < attribs.length; i++)
+            {
+                if (!(attribs[i].isSimpleType() || attribs[i].isAnyType()))
+                    typeSet.add(attribs[i].getTypeName());
+            }
+            
+            Iterator itr = typeSet.iterator();
+            while (itr.hasNext())
+            {
+                /*
+                 * Needed for self referenced array. <xsd:complexType
+                 * name="Type1"> <xsd:sequence> <xsd:element name="followings"
+                 * maxOccurs="unbounded" minOccurs="0" type="tns:Type1" />
+                 * <xsd:element name="kind" type="xsd:string" /> <xsd:element
+                 * name="index" type="xsd:int" /> </xsd:sequence> <xsd:attribute
+                 * name="att_kind" type="tns:Kind" /> </xsd:complexType>
+                 */
+                typeName = itr.next().toString();
+                if (!typeName.equals(type.getName().getLocalPart()))
+                {
+                    writer.write("extern int Axis_DeSerialize_" + typeName
+                            + "(" + typeName + "* param, IWrapperSoapDeSerializer* pDZ);\n");
+                    writer.write("extern void* Axis_Create_" + typeName + "("
+                            + typeName + "* pObj, bool bArray = false, int nSize=0);\n");
+                    writer.write("extern void Axis_Delete_" + typeName + "("
+                            + typeName + "* param, bool bArray = false, int nSize=0);\n");
+                    writer.write("extern int Axis_Serialize_" + typeName + "("
+                            + typeName + "* param, IWrapperSoapSerializer* pSZ, bool bArray = false);\n");
+                    writer.write("extern int Axis_GetSize_" + typeName + "();\n\n");
+                } 
+                else
+                {
+                    writer.write("int Axis_DeSerialize_" + typeName + "("
+                            + typeName + "* param, IWrapperSoapDeSerializer* pDZ);\n");
+                    writer.write("void* Axis_Create_" + typeName + "("
+                            + typeName + "* pObj, bool bArray, int nSize);\n");
+                    writer.write("void Axis_Delete_" + typeName + "("
+                            + typeName + "* param, bool bArray, int nSize);\n");
+                    writer.write("int Axis_Serialize_" + typeName
+                                    + "(" + typeName
+                                    + "* param, IWrapperSoapSerializer* pSZ, bool bArray);\n");
+                    writer.write("int Axis_GetSize_" + typeName + "();\n\n");
+                }
+            }
 
-		int anyCounter = 0;
-		
-		if (type.isArray())
+            writeGetSetMethods();
+            writeSerializeGlobalMethod();
+            writeDeSerializeGlobalMethod();
+            writeCreateGlobalMethod();
+            writeDeleteGlobalMethod();
+            writeGetSizeGlobalMethod();
+        } 
+        catch (IOException e)
         {
-            return;
+            throw new WrapperFault(e);
         }
+    }
+
+    /**
+     * Dushshantha: following method writes getters and setters for the
+     * attributes
+     */
+
+    private void writeGetSetMethods() throws WrapperFault
+    {
+        /**
+         * Dushshantha: writing getter
+         */
+        int anyCounter = 0;
+        
+        if (type.isArray())
+            return;
+        
         try
         {
-			for (int i = 0; i < attribs.length; i++)
+            for (int i = 0; i < attribs.length; i++)
             {
-			    String parameterName = attribs[i]
-			       							.getParamNameWithoutSymbols();
-				String properParamName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]);
-				
-				if (attribs[i].isArray())
-				{
-                    writer.write("\n" + properParamName + " * " + classname
-                            + "::get" + parameterName + "()\n{\n");
+                attribs[i].setParamName( CUtils.sanitiseAttributeName( classname, attribs[i].getParamName()));
+
+                String methodName = attribs[i].getParamNameWithoutSymbols();
+                String parameterName = methodName;
+                String properParamName = getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]);
+                String type = attribs[i].getTypeName();
+
+                if( methodName.endsWith( "_"))
+                {
+                    String localMethodName = methodName.substring( 0, methodName.length() - 1);
+                    
+                    if( localMethodName.equals( classname))
+                        methodName = localMethodName; 
+                }
+                
+                if (attribs[i].isArray())
+                {
+                    String parameterTypeName = properParamName;
+                    if (!parameterTypeName.endsWith("*"))
+                        parameterTypeName += " *";
+                    
+                    writer.write("\n" + parameterTypeName + " " + classname
+                            + "::get" + methodName + "()\n{\n");
 
                     writer.write("\t" + "return " + parameterName + " ; \n}\n");
 
                     writer.write("\n" + "void " + classname + "::set"
-                            + parameterName + "(" + properParamName
-                            + " * pInValue)\n{\n");
+                            + methodName + "(" + parameterTypeName + " pInValue)\n{\n");
 
                     writer.write("\tif(" + parameterName + " == NULL)\n");
                     writer.write("\t{\n");
-                    writer.write("\t\t" + parameterName + " = new " + properParamName + "();\n");
+                    
+                    if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
+                    {
+                        writer.write("\t\t// This object is a 'choice' or 'all', so need to ensure that any\n");
+                        writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
+                        writer.write("\t\t// NB: Hasn't been implemented yet!\n");
+                        writer.write("\t\t" + parameterName + " = new " + type + "_Array();\n");
+                    }
+                    else
+                        writer.write("\t\t" + parameterName + " = new " + properParamName + "();\n");
+                    
                     writer.write("\t}\n");
-                    writer.write("\t" + parameterName + "->clone(*pInValue); \n");
+                    
+                    if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
+                        writer.write("\t" + parameterName + "->clone( *pInValue);\n");
+                    else
+                        writer.write("\t" + parameterName + "->clone( *pInValue);\n");
+
                     writer.write("}\n");
                 }
-				else
-				{
-	                // FJP Nillable vv
-	                if (isElementNillable(i))
-	                {
-						
-	
-						if (attribs[i].isAnyType())
-	                    {
-	                        anyCounter += 1;
-	                    	parameterName = parameterName + Integer.toString(anyCounter);
-	                    }
-						
-						writer.write("\n" + properParamName + " * " + classname
-								+ "::get" + parameterName + "()\n{\n");
-	
-						writer.write("\t" + "return " + parameterName + " ; \n}\n");
-	
-						writer.write("\n" + "void " + classname + "::set"
-								+ parameterName + "(" + properParamName
-								+ " * pInValue)\n{\n");
-	
-						writer.write("\t" + parameterName + " = pInValue ; \n");
-	
-						if (attribs[i].getChoiceElement())
-	                    {
-	                        for (int j = 0; j < attribs.length; j++)
-	                        {
-	                            if ((attribs[j].getChoiceElement()) && (j != i))
-	                            {
-									writer.write("\t"
-											+ attribs[j]
-													.getParamNameWithoutSymbols()
-											+ " = NULL ; \n");
-								}
-							}
-						}
-	
-						writer.write("}\n");
-					} 
-	                else 
-	                {
-						// FJP Nillable ^^
-						/**
-						 * Dushshantha: Write getter
-						 */
-	                    
-	                    if (attribs[i].isAnyType())
-	                    {
-	                        anyCounter += 1;
-	                    	parameterName = parameterName + Integer.toString(anyCounter);
-	                    }
-	
-	                    writer.write("\n"
-	                                    + properParamName
-	                                    + " " + classname + "::get"
-	                                    + parameterName
-	                                    + "()\n{\n");
-	
-	                    writer.write("\t" + "return "
-	                            + parameterName
-	                            + " ; \n}\n");
-	
-						/**
-						 * Dushshantha: Write setter
-						 */
-	
-	                    writer.write("\n"
-	                            + "void "
-	                            + classname
-	                            + "::set"
-	                            + parameterName
-	                            + "("
-	                            + properParamName
-	                            + " InValue)\n{\n");
-	
-	                    writer.write("\t" + parameterName
-	                            + " = InValue ; \n");
-	
-						if (attribs[i].getChoiceElement())
-	                    {
-	                        for (int j = 0; j < attribs.length; j++)
-	                        {
-	                            if ((attribs[j].getChoiceElement()) && (j != i))
-	                            {
-									writer.write("\t"
-											+ attribs[j].getParamNameWithoutSymbols()
-											+ " = NULL ; \n");
-								}
-							}
-						}
-	
-						writer.write("}\n");
-					}
-				}
-			}
-		} 
-        catch (IOException e) 
+                else if (isElementNillable(i)  || isElementOptional(i))
+                {
+                    if (attribs[i].isAnyType())
+                    {                        
+                        anyCounter += 1;
+                        parameterName = parameterName + Integer.toString(anyCounter);
+                    }
+                    
+                    if(attribs[i].getAllElement() || attribs[i].getChoiceElement() )
+                    {
+                        if (isElementNillable(i))
+                            writer.write("\n" + properParamName + " * " + classname
+                                + "::get" + methodName + "()\n{\n");
+                        else 
+                            writer.write("\n" + properParamName + " " + classname
+                                    + "::get" + methodName + "()\n{\n");
+                    }
+                    else
+                    {
+                        writer.write("\n" + properParamName + " * " + classname
+                                + "::get" + methodName + "()\n{\n");
+                    }
+                    
+                    writer.write("\t" + "return " + parameterName + " ; \n}\n");
+
+                    if(attribs[i].getAllElement() || attribs[i].getChoiceElement())
+                    {
+                        if (isElementNillable(i))
+                            writer.write("\n" + "void " + classname + "::set"
+                                    + methodName + "(" + properParamName
+                                    + " * pInValue, bool deep)\n{\n");
+                        else
+                            writer.write("\n" + "void " + classname + "::set"
+                                + methodName + "(" + properParamName
+                                + " pInValue, bool deep)\n{\n");
+                    }
+                    else
+                    {
+                        writer.write("\n" + "void " + classname + "::set"
+                                + methodName + "(" + properParamName
+                                + " * pInValue, bool deep)\n{\n");
+                    }
+                    
+                    writer.write("\tif (" + parameterName + " != NULL)\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\tif (__axis_deepcopy_" + parameterName + ")\n");
+                    writer.write("\t\t{\n");
+                    writer.write("\t\t\tdelete " + parameterName + ";\n");
+                    writer.write("\t\t}\n");
+                    writer.write("\t\t" + parameterName + " = NULL;\n");
+                    writer.write("\t}\n");
+                    writer.write("\tif (pInValue != NULL)\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\tif (deep)\n");
+                    writer.write("\t\t{\n");
+                    
+                    if(attribs[i].getAllElement() || attribs[i].getChoiceElement())
+                    {
+                        if (isElementNillable(i))
+                            writer.write("\t\t\t" + parameterName + " = new " + type + "*();\n");
+                        else
+                            writer.write("\t\t\t" + parameterName + " = new " + type + "();\n");
+                    }
+                    else
+                    {
+                        writer.write("\t\t\t" + parameterName + " = new " + properParamName + "();\n");
+                    }
+                    
+                    writer.write("\t\t\t*" + parameterName + " = *pInValue;\n");
+                    writer.write("\t\t}\n");
+                    writer.write("\t\telse\n");
+                    writer.write("\t\t{\n");
+                    writer.write("\t\t\t" + parameterName + " = pInValue;\n");
+                    writer.write("\t\t}\n");
+                    writer.write("\t}\n");
+                    writer.write("\telse\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\t" + parameterName + " = NULL;\n");
+                    writer.write("\t}\n");
+                    writer.write("\t__axis_deepcopy_" + parameterName + " = deep;\n");
+
+                    if (attribs[i].getChoiceElement())
+                        for (int j = 0; j < attribs.length; j++)
+                        {
+                            if ((attribs[j].getChoiceElement()) && (j != i))
+                            {
+                                writer.write("\t"
+                                        + attribs[j].getParamNameWithoutSymbols()
+                                        + " = NULL ; \n");
+                            }
+                        }
+                    
+                    if (attribs[i].getAllElement())
+                        for (int j = 0; j < attribs.length; j++)
+                        {
+                            if ((attribs[j].getAllElement()) && (j != i))
+                            {
+                                writer.write("\t"
+                                        + attribs[j].getParamNameWithoutSymbols()
+                                        + " = NULL ; \n");
+                            }
+                        }
+
+                    writer.write("}\n");
+                } 
+                else
+                {
+                    /**
+                     * Dushshantha: Write getter
+                     */
+                
+                    if (attribs[i].isAnyType())
+                    {                        
+                        anyCounter += 1;
+                        parameterName = parameterName + Integer.toString(anyCounter);
+                        methodName = methodName + Integer.toString(anyCounter);
+                    }
+
+                    writer.write("\n"
+                            + properParamName + " " + classname + "::get" + methodName
+                            + "()\n{\n");
+
+                    writer.write("\t" + "return " + parameterName + " ; \n}\n");
+
+                    /**
+                     * Dushshantha: Write setter
+                     */
+
+                    writer.write("\n"
+                            + "void " + classname + "::set"
+                            + methodName + "(" + properParamName + " InValue");
+                    
+                    Type attributeType = attribs[i].getType();
+                    
+                    boolean isPointerType = false;
+                    if (attributeType.isSimpleType())
+                        isPointerType = CUtils.isPointerType(CUtils.getclass4qname(attributeType.getBaseType())); 
+                    else
+                        isPointerType = CUtils.isPointerType(getCorrectParmNameConsideringArraysAndComplexTypes(attribs[i]));
+                    
+                    if((attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()) 
+                            && (isPointerType || attribs[i].getAllElement() || attribs[i].getChoiceElement()))
+                        writer.write(", bool deep");
+                    
+                    writer.write(")\n{\n");
+                    
+                    if(isPointerType)
+                    {
+                        writer.write("\tif (" + parameterName + " != NULL)\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\tif (__axis_deepcopy_" + parameterName + ")\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\tdelete [] " + parameterName + ";\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t\t" + parameterName + " = NULL;\n");
+                        writer.write("\t}\n\n");
+                        writer.write("\tif(InValue != NULL)\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\tif (deep)\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\t" + parameterName + " = new char[strlen(InValue) + 1];\n");
+                        writer.write("\t\t\tstrcpy(" + parameterName + ", InValue);\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t\telse\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\t" + parameterName + " = InValue;\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t}\n");
+                        writer.write("\telse\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\t" + parameterName + " = NULL;\n");
+                        writer.write("\t}\n");
+                        writer.write("\t__axis_deepcopy_" + parameterName + " = deep;\n");
+                    }
+                    else if ((attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()) 
+                                && (attribs[i].getAllElement() || attribs[i].getChoiceElement()))
+                    {
+                        writer.write("\tif (" + parameterName + " != NULL)\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\tif (__axis_deepcopy_" + parameterName + ")\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\tdelete " + parameterName + ";\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t\t" + parameterName + " = NULL;\n");
+                        writer.write("\t}\n");
+                        writer.write("\tif (InValue != NULL)\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\tif (deep)\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\t" + parameterName + " = new " + type + "();\n");
+                        writer.write("\t\t\t*" + parameterName + " = *InValue;\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t\telse\n");
+                        writer.write("\t\t{\n");
+                        writer.write("\t\t\t" + parameterName + " = InValue;\n");
+                        writer.write("\t\t}\n");
+                        writer.write("\t}\n");
+                        writer.write("\telse\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\t" + parameterName + " = NULL;\n");
+                        writer.write("\t}\n");
+                        writer.write("\t__axis_deepcopy_" + parameterName + " = deep;\n");
+                    }
+                    else
+                        writer.write("\t" + parameterName + " = InValue ; \n");
+
+                    if (attribs[i].getChoiceElement())
+                        for (int j = 0; j < attribs.length; j++)
+                        {
+                            if ((attribs[j].getChoiceElement()) && (j != i))
+                                writer.write("\t" + attribs[j].getParamNameWithoutSymbols() + " = NULL ; \n");
+                        }
+
+                    writer.write("}\n");
+                }
+            } // for loop
+        } 
+        catch (IOException e)
         {
-			throw new WrapperFault(e);
-		}
+            throw new WrapperFault(e);
+        }
+
 	}
 
-	private void writeGetSizeGlobalMethod() throws IOException 
+    private void writeGetSizeGlobalMethod() throws IOException
     {
-		writer.write("/*\n");
-		writer.write(" * This static method gives the size of " + classname
-				+ " type of object\n");
-		writer.write(" */\n");
-		writer.write("int Axis_GetSize_" + classname
-				+ "()\n{\n\treturn sizeof(" + classname + ");\n}\n");
-	}
+        writer.write("/*\n");
+        writer.write(" * This static method gives the size of " + classname + " type of object\n");
+        writer.write(" */\n");
+        writer.write("int Axis_GetSize_" + classname + "()\n{\n\treturn sizeof(" + classname + ");\n}\n");
+    }
 
 	private void writeSerializeGlobalMethod() throws IOException, WrapperFault 
     {
-		writer.write("/*\n");
-		writer.write(" * This static method serialize a " + classname
-				+ " type of object\n");
-		writer.write(" */\n");
-		writer.write("int Axis_Serialize_"
-						+ classname
-						+ "("
-						+ classname
-						+ "* param, IWrapperSoapSerializer* pSZ, bool bArray = false)\n{\n");
+		writer.write( "/*\n");
+		writer.write( " * This static method serialize a " + classname + " type of object\n");
+		writer.write( " */\n");
+		writer.write( "int Axis_Serialize_" +
+		              classname	+
+		              "( " +
+		              classname	+
+		              "* param, IWrapperSoapSerializer* pSZ, bool bArray = false)\n");
+		writer.write( "{\n");
 
 		if (attribs.length == 0) 
         {
-			System.out.println("Possible error in class " + classname
-					+ ": class with no attributes....................");
-			writer.write("\t}\n\n");
-			return;
-		}
-		writer.write("\tif (bArray)\n");
-		writer.write("\t{\n");
-		writer.write("\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
-				+ ", \">\", NULL);\n");
-		writer.write("\t}\n");
-		writer.write("\telse\n");
-		writer.write("\t{\n");
-		writer.write("\t\tbool blnIsNewPrefix = false;\n");
-		writer
-				.write("\t\tconst AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_"
-						+ classname + ", blnIsNewPrefix);\n");
-		writer.write("\t\tif (!blnIsNewPrefix)\n");
-		writer.write("\t\t{\n");
-		writer.write("\t\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
-				+ ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
-		writer.write("\t\t\t\tAxis_TypeName_" + classname
-				+ ", \"\\\">\", NULL);\n");
-		writer.write("\t\t}\n");
-		writer.write("\t\telse\n");
-		writer.write("\t\t{\n");
-		writer.write("\t\t\tpSZ->serialize(\"<\", Axis_TypeName_" + classname
-				+ ", \" xsi:type=\\\"\", sPrefix, \":\",\n");
-		writer.write("\t\t\t\tAxis_TypeName_" + classname
-				+ ", \"\\\" xmlns:\", sPrefix, \"=\\\"\",\n");
-		writer.write("\t\t\t\tAxis_URI_" + classname + ", \"\\\">\", NULL);\n");
-		writer.write("\t\t}\n");
-		writer.write("\t}\n\n");
-
-		String arrayType;
-		boolean firstIfWritten = false;
-		int anyCounter = 0;
+            writer.write("\tpSZ->serialize(\">\", NULL);\n");
+
+            if (extensionBaseAttrib != null)
+            {
+                String typeName = extensionBaseAttrib.getTypeName();
+                writer.write("\tpSZ->serializeAsChardata((void*)");
+                
+                if (!CUtils.isPointerType(typeName))
+                    writer.write("&");
+                
+                writer.write("(param->"
+                        + extensionBaseAttrib.getParamNameAsMember()
+                        + "), "
+                        + CUtils.getXSDTypeForBasicType(typeName) + ");\n");
+            } 
+            else
+            {
+                System.out.println("Possible error in class " + classname
+                        + ": class with no attributes....................");
+            }
+            
+            writer.write("\treturn AXIS_SUCCESS;\n");
+            writer.write("}\n\n");
+            return;
+        }
 		
-		for (int i = 0; i < attribs.length; i++) 
+        String arrayType;
+        
+        
+        /*
+         * A type does not know whether it is used as a nillable parameter So
+         * this may not be the appropriate place to do this
+         */
+        writer.write("\tif ( param == NULL )\n\t{\n");
+        writer.write("\t\tpSZ->serializeAsAttribute( \"xsi:nil\", 0, (void*)&(xsd_boolean_true), XSD_BOOLEAN);\n");
+        writer.write("\t\tpSZ->serialize( \">\", NULL);\n");
+        writer.write("\t\treturn AXIS_SUCCESS;\n");
+        writer.write("\t}\n\n");
+        /*
+         * This is the only real difference for the serializer between rpc/encoded and doc/literal objects
+         * 
+         */
+        if (wscontext.getWrapInfo().getWrapperStyle().equals("rpc"))
         {
-			//Dushshantha:
-			//if the attribute is a choice following should do
-
-			if (attribs[i].getChoiceElement())
+            writeRPCArrayPortionOfSerializeGlobalMethod();
+    		
+        }
+        else
+        {
+            writeDOCArrayPortionOfSerializeGlobalMethod();
+        }
+        writer.write( "\t\t}\n");
+        writer.write( "\t}\n\n");
+        
+        writer.write("\t/* If there are any attributes serialize them. If there aren't then close the tag */\n");
+        for (int i = 0; i < attributeParamCount; i++)
+        {
+            if (attribs[i].isArray() || !(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()))
             {
-                if (!firstIfWritten)
+                throw new WrapperFault("Error : an attribute is not basic type");
+            }
+            else
+            {
+                //remove _Ref sufix and _ prefix in SOAP tag name
+                String soapTagName = attribs[i].getParamName();
+                if (soapTagName.lastIndexOf("_Ref") > -1)
+                    soapTagName = soapTagName.substring(0, soapTagName.lastIndexOf("_Ref"));
+                
+                if (soapTagName.charAt(0) == '_')
+                    soapTagName = soapTagName.substring(1, soapTagName.length());
+
+                Type type = attribs[i].getType();
+                boolean isPointerType = false;
+                String basicType = null;
+                
+                if (!attribs[i].isSimpleType() && type.isSimpleType())
                 {
-                    writer.write("\tif");
-                    firstIfWritten = true;
+                    basicType = CUtils.getclass4qname(attribs[i].getType().getBaseType());
+                    isPointerType = CUtils.isPointerType(CUtils.getclass4qname(type.getBaseType())); 
                 }
                 else
                 {
-                    writer.write("\telse if");
+                    basicType = attribs[i].getTypeName();
+                    isPointerType = CUtils.isPointerType(attribs[i].getTypeName());
+                }
+                
+                if (isPointerType)
+                {
+                    writer.write("\tif (0 != param->" + attribs[i].getParamNameAsMember() + ")\n");
+                    writer.write("\t\tpSZ->serializeAsAttribute(\""
+                            + soapTagName + "\", 0, (void*)(param->"
+                            + attribs[i].getParamNameAsMember() + "), "
+                            + CUtils.getXSDTypeForBasicType(basicType) + ");\n");
                 }
+                else
+                {
+                    writer.write("\t\tpSZ->serializeAsAttribute(\""
+                            + soapTagName
+                            + "\", 0, (void*)&(param->"
+                            + attribs[i].getParamNameAsMember()
+                            + "), "
+                            + CUtils.getXSDTypeForBasicType(attribs[i].getTypeName()) + ");\n");
+                }
+                
+                if (!attribs[i].isOptional())
+                {
+                    /* This avoid segmentation fault at runtime */
+                    /*
+                     * writer.write("\telse\n");
+                     * writer.write("\t\tAXISTRACE1(\"The mandatory attribute
+                     * "+attribs[i].getParamName()+" is not set\",
+                     * CRITICAL);\n");
+                     */
+                }
+            }
+        }
+        
+        if (type.isFault())
+        {
+            writer.write("\tif(Axis_URI_" + classname + ")\n\t{\n");
+            writer.write("\t\tbool blnIsNewPrefix = false;\n");
+            writer.write("\t\tconst AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_"
+                        + classname + ", blnIsNewPrefix);\n");
+            writer.write("\t\tpSZ->serialize(\" xmlns:\", sPrefix, \"=\\\"\",");
+            writer.write("Axis_URI_" + classname + ", \" " + " \\\"\"");
+            writer.write(", NULL);\n\t}\n");
+        }               
+        
+        writer.write("\tpSZ->serialize( \">\", 0);\n");
+        if (extensionBaseAttrib != null)
+        {
+            String typeName = extensionBaseAttrib.getTypeName(); 
+            if( typeName != null)
+            {
+                writer.write("\tpSZ->serializeAsChardata((void*)");
+                if (!CUtils.isPointerType(typeName))
+                    writer.write("&");
 
-				writer.write("(param->" + attribs[i].getParamNameAsMember()
-						+ ")\n\t{\n\t");
-			}
+                writer.write("(param->" + extensionBaseAttrib.getParamNameAsMember() + "), "
+                        + CUtils.getXSDTypeForBasicType(typeName) + ");\n");
+            }
+        }
 
-			//Chinthana:
-			//if the attribute is a 'all' following should do
+        writer.write("\n\t/* then serialize elements if any*/\n");
 
-			if (attribs[i].getAllElement())
+        boolean firstIfWritten = false;
+        int anyCounter = 0; //counter for any types.
+        
+        for (int i = attributeParamCount; i < attribs.length; i++)
+        {
+            String namespace = "";
+            if (attribs[i].getNsQualified())
+                namespace = "Axis_URI_" + classname;
+            else
+                namespace = "NULL";
+            
+            // if the attribute is a choice following should do
+            if (attribs[i].getChoiceElement())
             {
+                if (!firstIfWritten)
+                {
+                    writer.write("\tif");
+                    firstIfWritten = true;
+                } 
+                else
+                    writer.write("\telse if");
+
+                writer.write("(param->" + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
+            }
+ 
+            //if the attribute is a 'all' following should do
+            if (attribs[i].getAllElement())
                 if (attribs[i].getMinOccurs() == 0)
+                    writer.write("\tif(param->" + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
+             
+            if (attribs[i].isAnyType())
+            {
+                anyCounter += 1;
+                writer.write("\tpSZ->serializeAnyObject(param->any" + Integer.toString(anyCounter) +");\n");
+            }
+            else if (attribs[i].isArray())
+            {
+                if (attribs[i].isSimpleType() || attribs[i].getType().isSimpleType())
+                {
+                    String baseTypeName = null;
+                    if (!attribs[i].isSimpleType() && attribs[i].getType().isSimpleType())
+                        baseTypeName = CUtils.getclass4qname(attribs[i].getType().getBaseType());
+                    else
+                        baseTypeName = attribs[i].getTypeName();
+                    
+                    writer.write("\tpSZ->serializeBasicArray(param->" + attribs[i].getParamName()
+                        + ", " + namespace + ","
+                        + CUtils.getXSDTypeForBasicType(baseTypeName) + ", \""
+                        + attribs[i].getParamNameAsSOAPElement() + "\");\n");
+                }
+                else
                 {
-                    writer.write("\tif(param->"
-                            + attribs[i].getParamNameAsMember() + ")\n\t{\n\t");
+                    arrayType = attribs[i].getTypeName();
+                    
+                    if (attribs[i].getNsQualified())
+                        namespace = "Axis_URI_" + arrayType;
+                    else
+                        namespace = "NULL";
+                    
+                    writer.write("\tpSZ->serializeCmplxArray(param->"
+                                    + attribs[i].getParamNameAsMember() + ",\n");
+                    writer.write("\t\t\t\t\t\t (void*) Axis_Serialize_" + arrayType + ",\n");
+                    writer.write("\t\t\t\t\t\t (void*) Axis_Delete_" + arrayType + ",\n");
+                    writer.write("\t\t\t\t\t\t (void*) Axis_GetSize_" + arrayType + ",\n");
+                    writer.write("\t\t\t\t\t\t \""
+                            + attribs[i].getElementNameAsString() + "\", " + namespace + ");\n");
                 }
             }
-
-			if (attribs[i].isAnyType()) 
+            else if (attribs[i].isSimpleType() || attribs[i].getType().isSimpleType())
             {
-				anyCounter += 1;
-            	writer.write("\tpSZ->serializeAnyObject(param->any" + Integer.toString(anyCounter) +");\n");
-			} 
-            else if (attribs[i].isArray()) 
-            {
-				//if Array
-				if (attribs[i].isSimpleType()) 
-                {
-					writer.write("\tpSZ->serializeBasicArray(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ ","
-									+ CUtils.getXSDTypeForBasicType(attribs[i]
-											.getTypeName())
-									+ ", \""
-									+ attribs[i].getParamName() + "\");\n");
-				}
-                else
-                {
-                    String elm = attribs[i].getParamName();
-                    if (attribs[i].isReference())
-                    {
-                        elm = attribs[i].getTypeName();
-                    }
-					arrayType = attribs[i].getTypeName();
-					writer.write("\tpSZ->serializeCmplxArray(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ ",\n");
-					writer.write("\t\t(void*) Axis_Serialize_" + arrayType
-							+ ", (void*) Axis_Delete_" + arrayType
-							+ ", (void*) Axis_GetSize_" + arrayType + ",\n");
-					writer.write("\t\t\"" + elm + "\", Axis_URI_" + arrayType
-							+ ");\n");
-				}
-			}
-            else if (attribs[i].isSimpleType())
-            {
-                if (attribs[i].isAttribute())
-                {
-                    if (attribs[i].isOptional())
-                    {
-						writer.write("\tif (0 != param->"
-								+ attribs[i].getParamNameAsMember() + ")\n");
-						if (attribs[i].getTypeName().equals("xsd__string")
-								|| attribs[i].getTypeName().equals("xsd__anyURI")
-								|| attribs[i].getTypeName().equals("xsd__QName")
-								|| attribs[i].getTypeName().equals("xsd__NOTATION")) 
-                        {
-							writer.write("\t\tpSZ->serializeAsAttribute(\""
-									+ attribs[i].getParamName()
-									+ "\", 0, (void*)(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ "), "
-									+ CUtils.getXSDTypeForBasicType(attribs[i]
-											.getTypeName()) + ");\n");
-						} 
-                        else 
-                        {
-							writer.write("\t\tpSZ->serializeAsAttribute(\""
-									+ attribs[i].getParamName()
-									+ "\", 0, (void*)&(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ "), "
-									+ CUtils.getXSDTypeForBasicType(attribs[i]
-											.getTypeName()) + ");\n");
-						}
-					} 
-                    else 
-                    {
-						writer.write("\tpSZ->serializeAsAttribute(\""
-								+ attribs[i].getParamName()
-								+ "\", 0, (void*)&(param->"
-								+ attribs[i].getParamNameAsMember()
-								+ "), "
-								+ CUtils.getXSDTypeForBasicType(attribs[i]
-										.getTypeName()) + ");\n");
-					}
-				} 
-                else 
-                {
-					if (attribs[i].getTypeName().equals("xsd__string")
-							|| attribs[i].getTypeName().equals("xsd__anyURI")
-							|| attribs[i].getTypeName().equals("xsd__QName")
-							|| attribs[i].getTypeName().equals("xsd__NOTATION")
-							|| isElementNillable(i)) 
-                    {
-						writer.write("\tpSZ->serializeAsElement(\""
-								+ attribs[i].getParamName()
-								+ "\", (void*)(param->"
-								+ attribs[i].getParamNameAsMember()
-								+ "), "
-								+ CUtils.getXSDTypeForBasicType(attribs[i]
-										.getTypeName()) + ");\n");
-					} 
-                    else 
-                    {
-						/**
-						 * Dushshantha: if the element is a choice element, it
-						 * should be treated as a pointer
-						 */
-						if (attribs[i].getChoiceElement()
-								|| attribs[i].getAllElement())
-                        {
-							writer.write("\tpSZ->serializeAsElement(\""
-									+ attribs[i].getParamName()
-									+ "\", (void*)(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ "), "
-									+ CUtils.getXSDTypeForBasicType(attribs[i]
-											.getTypeName()) + ");\n");
-                        }
-						else
-                        {
-							writer.write("\tpSZ->serializeAsElement(\""
-									+ attribs[i].getParamName()
-									+ "\", (void*)&(param->"
-									+ attribs[i].getParamNameAsMember()
-									+ "), "
-									+ CUtils.getXSDTypeForBasicType(attribs[i]
-											.getTypeName()) + ");\n");
-                        }
-					}
-				}
-			} 
-            else 
-            {
-				//if complex type
-				writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
-						+ "(param->" + attribs[i].getParamNameAsMember()
-						+ ", pSZ);\n");
-			}
-			//Dushshantha:
-			//end if choice element
+                String typeName = attribs[i].getTypeName();
+                String baseTypeName = null;
+                if (attribs[i].getType().isSimpleType())
+                    baseTypeName = CUtils.getclass4qname (attribs[i].getType().getBaseType ());
+                else
+                    baseTypeName = typeName;
+                
+                if (attribs[i].isOptional())
+                    writer.write("\tif (param->" + attribs[i].getParamNameWithoutSymbols() + " != NULL)\n\t{\n\t");
+                
+                if (CUtils.isPointerType(baseTypeName))
+                {
+                    writer.write("\tpSZ->serializeAsElement(\""
+                            + attribs[i].getSOAPElementNameAsString()
+                            + "\", " + namespace
+                            + ", (void*)(param->" + attribs[i].getParamNameWithoutSymbols() + "), "
+                            + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
+                }
+                else if (attribs[i].getChoiceElement()
+                            || attribs[i].getAllElement()
+                            || isElementNillable(i) || isElementOptional(i))
+                {
+                    // If the simple type is a choice it is handled
+                    // as a pointer variable. These variables should be defined
+                    // as pointers in the header file. This is the same in 'all' element
+                    
+                    if (((attribs[i].getChoiceElement())
+                            && (isElementNillable(i)))
+                            && !(CUtils.isPointerType(attribs[i].getTypeName())) )
+                    {
+                        writer.write("\tpSZ->serializeAsElement(\""
+                                + attribs[i].getSOAPElementNameAsString() + "\", " + namespace
+                                + ", (void*)(*(param->" + attribs[i].getParamNameWithoutSymbols()
+                                + ")), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
+                    }
+                    else
+                    {
+                        writer.write("\tpSZ->serializeAsElement(\""
+                                + attribs[i].getSOAPElementNameAsString() + "\", " + namespace
+                                + ", (void*)(param->" + attribs[i].getParamNameWithoutSymbols()
+                                + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
+                    }    
+                }                           
+                else
+                {
+                    writer.write("\tpSZ->serializeAsElement(\""
+                            + attribs[i].getSOAPElementNameAsString() + "\", " + namespace
+                            + ", (void*)&(param->" + attribs[i].getParamNameWithoutSymbols()
+                            + "), " + CUtils.getXSDTypeForBasicType(baseTypeName) + ");\n");
+                }
+                
+                if (attribs[i].isOptional())
+                    writer.write("\t}\n");
+            }
+            else
+            {
+                //if complex type
+                String elm = attribs[i].getParamName();
+                if (elm.lastIndexOf("_Ref") > -1)
+                    elm = elm.substring(0, elm.lastIndexOf("_Ref"));
+
+                if (elm.charAt(0) == '_')
+                    elm = elm.substring(1, elm.length());
+                
+                if (attribs[i].isReference())
+                    elm = attribs[i].getTypeName();
+                
+                if (attribs[i].isOptional())
+                    writer.write("\tif (param->" + attribs[i].getParamName() + " != NULL)\n\t{\n");
+                
+                if (attribs[i].getNsQualified())
+                {
+                    writer.write("\tpSZ->serialize(\"<\", pSZ->getNamespacePrefix(\""
+                                    + type.getName().getNamespaceURI()
+                                    + "\"), \":\", \"" + elm + "\", 0);\n");
+                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                            + "(param->" + attribs[i].getParamName() + ", pSZ);\n");
+                    writer.write("\tpSZ->serialize(\"</\", pSZ->getNamespacePrefix(\""
+                                    + type.getName().getNamespaceURI()
+                                    + "\"), \":\", \"" + elm + "\", \">\", 0);\n");
+                }
+                else
+                {
+                    writer.write("\tpSZ->serialize(\"<" + elm + "\", 0);\n");
+                    writer.write("\tAxis_Serialize_" + attribs[i].getTypeName()
+                            + "(param->" + attribs[i].getParamName() + ", pSZ);\n");
+                    writer.write("\tpSZ->serialize(\"</" + elm + "\", \">\", 0);\n");
+                }
+                
+                if (attribs[i].isOptional())
+                    writer.write("\t}\n");
+            }
 
-			if (attribs[i].getChoiceElement())
-				writer.write("\t}\n");
+            //end if choice element
 
-			//Chinthana: end if
-			if (attribs[i].getAllElement())
-            {
+            if (attribs[i].getChoiceElement())
+                writer.write("\t}\n");
+            
+            if (attribs[i].getAllElement())
                 if (attribs[i].getMinOccurs() == 0)
                     writer.write("\t}\n");
-            }
-		}
-		writer.write("\n\tpSZ->serialize(\"</\", Axis_TypeName_" + classname
-				+ ", \">\", NULL);\n");
-		writer.write("\treturn AXIS_SUCCESS;\n");
-		writer.write("}\n\n");
+        }
 
-	}
+        writer.write("\n\tif (!bArray && blnIsNewPrefix)\n");
+        writer.write("\t{\n");
+        writer.write("\t\tpSZ->removeNamespacePrefix(Axis_URI_" + classname + ");\n");
+        writer.write("\t}\n\n");
+        
+        writer.write("\treturn AXIS_SUCCESS;\n");
+        writer.write("}\n\n");
+    }
 
-	private void writeDeSerializeGlobalMethod() throws IOException, WrapperFault 
+    /**
+     * @throws IOException
+     */
+    private void writeDOCArrayPortionOfSerializeGlobalMethod() throws IOException
     {
-		int arrayCount = 0;
-		
-		writer.write("/*\n");
-		writer.write(" * This static method deserialize a " + classname
-				+ " type of object\n");
-		writer.write(" */\n");
-		writer.write("int Axis_DeSerialize_" + classname + "(" + classname
-				+ "* param, IWrapperSoapDeSerializer* pIWSDZ)\n{\n");
+        // For doc/literal objects
+        writer.write("\tbool blnIsNewPrefix = false;\n");
+        writer.write("\tif (!bArray)\n\t{\n");
+        writer.write("\t\tconst AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_" + classname + ", blnIsNewPrefix);\n");
+        writer.write("\t\tif (blnIsNewPrefix)\n\t\t{\n");
+        writer.write("\t\t\tpSZ->serialize(\" xmlns:\", sPrefix, \"=\\\"\",\n");
+        writer.write("\t\t\t\tAxis_URI_" + classname + ", \"\\\"\", NULL );\n");
+    }
 
-		if (attribs.length == 0) 
+    /**
+     * @throws IOException
+     */
+    private void writeRPCArrayPortionOfSerializeGlobalMethod() throws IOException
+    {
+        // For rpc/encoded objects
+        writer.write("\tbool blnIsNewPrefix = false;\n");
+        writer.write( "\tif( bArray)\n");
+        writer.write( "\t{\n");
+        writer.write( "\t\tpSZ->serialize( \"<\", Axis_TypeName_" + classname + ", \">\", NULL);\n");
+        writer.write( "\t}\n");
+        writer.write( "\telse\n");
+        writer.write( "\t{\n");
+        writer.write( "\t\tconst AxisChar *\tsPrefix = pSZ->getNamespacePrefix( Axis_URI_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tblnIsNewPrefix);\n\n");
+        writer.write( "// If there are objects that require a local namespace, then define it here.\n");
+        writer.write( "// NB: This namespace will go out of scope when the closing tag is reached.\n");
+        writer.write( "\t\tif( !blnIsNewPrefix)\n");
+        writer.write( "\t\t{\n");
+        writer.write( "\t\t\tpSZ->serialize( \"<\",\n\t\t\t\t\t\t\tAxis_TypeName_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\" xsi:type=\\\"\",\n" +
+                      "\t\t\t\t\t\t\tsPrefix,\n" +
+                      "\t\t\t\t\t\t\t\":\",\n" +
+                      "\t\t\t\t\t\t\t");
+        writer.write( "Axis_TypeName_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\"\\\">\",\n" +
+                      "\t\t\t\t\t\t\tNULL);\n");
+        writer.write( "\t\t}\n");
+        writer.write( "\t\telse\n");
+        writer.write( "\t\t{\n");
+        writer.write( "\t\t\tpSZ->serialize( \"<\",\n" +
+                      "\t\t\t\t\t\t\tAxis_TypeName_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\" xsi:type=\\\"\",\n" +
+                      "\t\t\t\t\t\t\tsPrefix,\n" +
+                      "\t\t\t\t\t\t\t\":\",\n" +
+                      "\t\t\t\t\t\t\tAxis_TypeName_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\"\\\" xmlns:\",\n" +
+                      "\t\t\t\t\t\t\tsPrefix,\n" +
+                      "\t\t\t\t\t\t\t\"=\\\"\",\n" +
+                      "\t\t\t\t\t\t\tAxis_URI_" + classname + ",\n" +
+                      "\t\t\t\t\t\t\t\"\\\">\",\n" +
+                      "\t\t\t\t\t\t\tNULL);\n");
+    }
+
+    private void writeDeSerializeGlobalMethod() throws IOException, WrapperFault
+    {
+        int arrayCount = 0;
+        writer.write("/*\n");
+        writer.write(" * This static method deserialize a " + classname + " type of object\n");
+        writer.write(" */\n");
+        writer.write("int Axis_DeSerialize_" + classname + "(" + classname
+                + "* param, IWrapperSoapDeSerializer* pIWSDZ)\n{\n");
+
+        if (attribs.length == 0)
         {
-			System.out.println("Possible error in class " + classname
-					+ ": class with no attributes....................");
-			writer.write("\t}\n\n");
-			return;
-		}
-		String arrayType = null;
-
-		//Dushshantha:
-		//peekCalled boolean variable checks whether the Line
-		//const char* choiceName=pIWSDZ->peekNextElementName(); has been
-		// wriiten in the generated cade.
-		boolean peekCalled = false;
-		boolean firstIfWritten = false;
-		boolean foundAll = false;
-		int anyCounter = 0; //counter for any types.
-		
-		for (int i = 0; i < attribs.length; i++) 
+            if (extensionBaseAttrib != null)
+            {
+                writer.write("\tpIWSDZ->getChardataAs((void*)&(param->"
+                        + extensionBaseAttrib.getParamNameAsMember() + "), "
+                        + CUtils.getXSDTypeForBasicType(extensionBaseAttrib.getTypeName()) + ");\n");
+            }
+            else
+            {
+                System.out.println("Possible error in class " + classname
+                        + ": class with no attributes....................");
+            }
+            
+            writer.write("\treturn AXIS_SUCCESS;\n");
+            writer.write("}\n\n");
+            return;
+        }
+        
+        String arrayType = null;
+        boolean peekCalled = false;
+        boolean firstIfWritten = false;
+        boolean foundAll = false;
+        int anyCounter = 0; //counter for any types.
+        
+        for (int i = 0; i < attribs.length; i++)
         {
-			//Dushshantha:
-			//if the attribute is a choice following should do :-)
+            //if the attribute is a 'choice' construct we have to peek and make
+            // the choice
 
-			if (attribs[i].getChoiceElement()) 
+            if (attribs[i].getChoiceElement())
             {
-				if (!peekCalled) 
+                if (!peekCalled)
+                {
+                    writer.write("\tconst char* choiceName=pIWSDZ->peekNextElementName();\n");
+                    peekCalled = true;
+                }
+
+                if (!firstIfWritten)
+                {
+                    writer.write("\tif");
+                    firstIfWritten = true;
+                } 
+                else
+                    writer.write("\telse if");
+
+                writer.write("(strcmp(choiceName,\""
+                        + attribs[i].getElementNameAsString() + "\")==0)\n\t{\n\t");
+            }
+
+            //if the attribute is a 'all' construct we have to check Min
+            // occures
+            if (attribs[i].getAllElement())
+                if (attribs[i].getMinOccurs() == 0)
                 {
-					writer.write("\tconst char* choiceName=pIWSDZ->peekNextElementName();\n");
-					peekCalled = true;
-				}
-
-				if (!firstIfWritten) 
-                {
-					writer.write("\tif");
-					firstIfWritten = true;
-				} 
-                else 
-                {
-					writer.write("\telse if");
-				}
-
-				writer.write("(strcmp(choiceName,\""
-						+ attribs[i].getParamNameAsMember()
-						+ "\")==0)\n\t{\n\t");
-
-			}
-
-			//Chinthana:
-			//if the attribute is a 'all' construct we have to check Min
-			// occures
-			if (attribs[i].getAllElement()) 
-            {
-				if (attribs[i].getMinOccurs() == 0) 
-                {
-					if (!foundAll) 
-                    {
-						writer.write("\tconst char* allName = NULL;\n");
-						writer.write("\tbool peekCalled = false;\n");
-						foundAll = true;
-					}
-
-					writer.write("\n\tif(!peekCalled)\n\t{\n\t");
-					writer.write("\tallName=pIWSDZ->peekNextElementName();\n");
-					writer.write("\t\tpeekCalled = true;\n");
-					writer.write("\t}\n");
-					writer.write("\tif(strcmp(allName,\""
-							+ attribs[i].getParamNameAsMember()
-							+ "\")==0)\n\t{\n\t");
-					writer.write("\tpeekCalled = false;\n\t");
-				}
-			}
-
-			if (attribs[i].isAnyType()) 
-            {
-				anyCounter +=1;
-            	writer.write("\tparam->any" + Integer.toString(anyCounter)+ " = pIWSDZ->getAnyObject();\n");
-			} 
-            else if (attribs[i].isArray()) 
-            {
-				//if Array
-				if (attribs[i].isSimpleType()) 
-                {
-					//new array memory model.					
-					 writer.write("\tAxis_Array * array" + arrayCount + " = pIWSDZ->getBasicArray("
-	                            + CUtils.getXSDTypeForBasicType(attribs[i].getTypeName()) + ", \""
-	                            + attribs[i].getParamNameAsSOAPElement()
-	                            + "\",0);\n");
-	                    writer.write("\tif(param->" + attribs[i].getParamNameAsMember() + " == NULL)\n");
-	                    writer.write("\t{\n");
-	                    writer.write("\t\tparam->" + attribs[i].getParamNameAsMember() + " = new " + attribs[i].getTypeName() + "_Array();\n");
-	                    writer.write("\t}\n");
-	                    writer.write("\tparam->" + attribs[i].getParamNameAsMember() + "->clone( *array" + arrayCount + ");\n");
-	                    writer.write("\tAxis::AxisDelete((void*) array" + arrayCount + ", XSD_ARRAY);\n\n");
-	                    //end of new array memory model.
-				} 
-                else 
-                {
-					String elm = attribs[i].getParamName();
-					if (attribs[i].isReference()) 
-                    {
-						elm = attribs[i].getTypeName();
-					}
-					arrayType = attribs[i].getTypeName();
-					
-					//new array memory model.
-					writer.write("\t" + arrayType + "_Array * array" + arrayCount + " = new " + arrayType + "_Array();\n");
-                    writer.write("\tarray" + arrayCount + " = (" + arrayType + "_Array *) pIWSDZ->getCmplxArray(array" + arrayCount + ", (void*)Axis_DeSerialize_"
-                                    + arrayType
-                                    + ",\n"
-                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Create_"
-                                    + arrayType
-                                    + ",\n"
-                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Delete_"
-                                    + arrayType
-                                    + ",\n"
-                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_GetSize_"
-                                    + arrayType
-                                    + ",\n"
+                    if (!foundAll)
+                    {
+                        writer.write("\tconst char* allName = NULL;\n");
+                        writer.write("\tbool peekCalled = false;\n");
+                        foundAll = true;
+                    }
+
+                    writer.write("\n\tif(!peekCalled)\n\t{\n\t");
+                    writer.write("\tallName=pIWSDZ->peekNextElementName();\n");
+                    writer.write("\t\tpeekCalled = true;\n");
+                    writer.write("\t}\n");
+                    writer.write("\tif(strcmp(allName,\""
+                            + attribs[i].getParamNameAsMember() + "\")==0)\n\t{\n\t");
+                    writer.write("\tpeekCalled = false;\n\t");
+                }
+            
+            if (attribs[i].isAnyType())
+            {
+                anyCounter +=1;
+                writer.write("\tparam->any" + Integer.toString(anyCounter)+ " = pIWSDZ->getAnyObject();\n");
+            }
+            else if (attribs[i].isArray())
+            {
+                arrayCount++;
+                //if Array
+                if (attribs[i].isSimpleType() || attribs[i].getType().isSimpleType())
+                {
+                    String baseTypeName = null;
+                    if (!attribs[i].isSimpleType() && attribs[i].getType().isSimpleType())
+                        baseTypeName = CUtils.getclass4qname(attribs[i].getType().getBaseType());
+                    else
+                        baseTypeName = attribs[i].getTypeName();
+
+                    writer.write("\tAxis_Array * array" + arrayCount + " = pIWSDZ->getBasicArray("
+                            + CUtils.getXSDTypeForBasicType(baseTypeName) + ", \""
+                            + attribs[i].getParamNameAsSOAPElement()
+                            + "\",0);\n");
+                    writer.write("\tif(param->" + attribs[i].getParamNameAsMember() + " == NULL)\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\tparam->" + attribs[i].getParamNameAsMember() + " = new " + attribs[i].getTypeName() + "_Array();\n");
+                    writer.write("\t}\n");
+                    writer.write("\tparam->" + attribs[i].getParamNameAsMember() + "->clone( *array" + arrayCount + ");\n");
+                    writer.write("\tAxis::AxisDelete((void*) array" + arrayCount + ", XSD_ARRAY);\n\n");
+                }
+                else
+                {
+                    arrayType = attribs[i].getTypeName();
+                    writer.write("\tpIWSDZ->getCmplxArray(param->" + attribs[i].getParamNameAsMember() + ", (void*)Axis_DeSerialize_"
+                                    + arrayType + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Create_" + arrayType + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_Delete_" + arrayType + ",\n"
+                                    + "\t\t\t\t\t\t\t\t  (void*)Axis_GetSize_" + arrayType + ",\n"
                                     + "\t\t\t\t\t\t\t\t  \""
                                     + attribs[i].getElementNameAsString()
                                     + "\", Axis_URI_" + arrayType + ");\n\n");
                     
-                	writer.write("\tparam->" + attribs[i].getParamNameAsMember() + " = array" + arrayCount + ";\n\n");
-                	//end of new array memory model.
-				}
-                arrayCount++;
-			} 
-            else if (attribs[i].isSimpleType()) 
+                }
+            }
+            else if ((attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()))
             {
-				if (attribs[i].isNillable()
-						|| attribs[i].getTypeName().equals("xsd__anyURI")
-						|| attribs[i].getTypeName().equals("xsd__QName")
-						|| attribs[i].getTypeName().equals("xsd__NOTATION")) 
-                {
-					//TODO handle optional attributes
-					writer.write("\t"
-							+ attribs[i].getTypeName()
-							+ "* p_"
-							+ attribs[i].getParamNameAsMember()
-							+ " = (pIWSDZ->"
-							+ CUtils.getParameterGetValueMethodName(attribs[i]
-									.getTypeName(), attribs[i].isAttribute())
-							+ "(\"" + attribs[i].getParamName() + "\",0));\n");
-					writer.write("\tparam->"
-							+ attribs[i].getParamNameAsMember() + " = *p_"
-							+ attribs[i].getParamNameAsMember() + ";\n");
-
-					writer.write("\tdelete p_"
-							+ attribs[i].getParamNameAsMember() + ";\n");
-				} 
-                else if (attribs[i].getTypeName().equals("xsd__string")
-						|| isElementNillable(i)) 
-                {
-					writer.write("\tparam->"
-							+ attribs[i].getParamNameAsMember()
-							+ " = pIWSDZ->"
-							+ CUtils.getParameterGetValueMethodName(attribs[i]
-									.getTypeName(), attribs[i].isAttribute())
-							+ "(\"" + attribs[i].getParamName() + "\",0);\n");
-				} 
-                else 
-                {
-					//TODO handle optional attributes
-					/**
-					 * Dushshantha: if the element is a choice element, it
-					 * should be treated as a pointer.
-					 */
-
-					if (attribs[i].getChoiceElement()
-							|| attribs[i].getAllElement())
-                    {
-						writer.write("\tparam->"
-								+ attribs[i].getParamNameAsMember()
-								+ " = (pIWSDZ->"
-								+ CUtils.getParameterGetValueMethodName(
-										attribs[i].getTypeName(), attribs[i]
-												.isAttribute()) + "(\""
-								+ attribs[i].getParamName() + "\",0));\n");
-                    }
-					else 
-                    {
-						writer.write("\t"
-								+ attribs[i].getTypeName()
-								+ "* p_"
-								+ attribs[i].getParamNameAsMember()
-								+ " = (pIWSDZ->"
-								+ CUtils.getParameterGetValueMethodName(
-										attribs[i].getTypeName(), attribs[i]
-												.isAttribute()) + "(\""
-								+ attribs[i].getParamName() + "\",0));\n");
-						writer.write("\tparam->"
-								+ attribs[i].getParamNameAsMember() + " = *p_"
-								+ attribs[i].getParamNameAsMember() + ";\n");
-						if (attribs[i].getTypeName().equals("xsd__hexBinary")
-									|| attribs[i].getTypeName().equals("xsd__base64Binary"))
-							writer.write("\n");
-						else
-							writer.write("\tdelete p_" + attribs[i].getParamNameAsMember() + ";\n");
-					}
-
-				}
-			} 
-            else 
-            {
-				writer.write("\tparam->" + attribs[i].getParamNameAsMember()
-						+ " = (" + attribs[i].getTypeName()
-						+ "*)pIWSDZ->getCmplxObject((void*)Axis_DeSerialize_"
-						+ attribs[i].getTypeName()
-						+ "\n\t\t, (void*)Axis_Create_"
-						+ attribs[i].getTypeName() + ", (void*)Axis_Delete_"
-						+ attribs[i].getTypeName() + "\n\t\t, \""
-						+ attribs[i].getParamNameAsSOAPElement()
-						+ "\", Axis_URI_" + attribs[i].getTypeName() + ");\n");
-			}
-
-			//Dushshantha:
-			//end if
-
-			if (attribs[i].getChoiceElement())
-				writer.write("\t}\n");
-
-			//Chinthana: end if
-			if (attribs[i].getAllElement()) 
-            {
-				if (attribs[i].getMinOccurs() == 0)
-					writer.write("\t}\n");
-			}
-		}
-		writer.write("\treturn pIWSDZ->getStatus();\n");
-		writer.write("}\n");
-	}
+                //TODO handle optional attributes
+                //remove _Ref sufix and _ prefix in SOAP tag name
+                String soapTagName = (attribs[i].isAttribute() ? attribs[i].getParamName() : attribs[i].getElementNameAsString());
+                if (soapTagName.lastIndexOf("_Ref") > -1)
+                    soapTagName = soapTagName.substring(0, soapTagName.lastIndexOf("_Ref"));
+
+                if (soapTagName.charAt(0) == '_')
+                    soapTagName = soapTagName.substring(1, soapTagName.length());
+                
+                if (attribs[i].isOptional())
+                {
+                    writer.write("\tconst char* elementName" + i + " = pIWSDZ->peekNextElementName();\n");
+                    writer.write("\t\tif(strcmp(elementName" + i + ", \"" + soapTagName + "\") == 0)\n");
+                    writer.write("\t\t{\n");
+                }
+                
+                Type type = attribs[i].getType();
+                boolean isPointerType = false;
+                if (type.isSimpleType())
+                    isPointerType = CUtils.isPointerType(CUtils.getclass4qname(type.getBaseType())); 
+                else
+                    isPointerType = CUtils.isPointerType(attribs[i].getTypeName());
+
+                if (attribs[i].isNillable() ||
+                        isElementNillable(i) ||
+                        isElementOptional(i) ||
+                        isPointerType)
+                {
+                    if (attribs[i].getChoiceElement() && isElementNillable(i) && !isPointerType)
+                    {
+                        writer.write("\tparam->"
+                                + attribs[i].getParamNameAsMember()
+                                + " = (" + attribs[i].getTypeName()
+                                + "**)(" + attribs[i].getTypeName()
+                                +"*)new " +attribs[i].getTypeName() + ";\n");
+                        
+                        writer.write("\t\t*(param->"
+                                + attribs[i].getParamNameAsMember() + ") = pIWSDZ->"
+                                + CUtils.getParameterGetValueMethodName(
+                                        attribs[i].getTypeName(), attribs[i].isAttribute()) + "( \""
+                                + soapTagName + "\",0);\n");
+                    }
+                    else
+                    {
+                        String typeName = attribs[i].getTypeName();
+                        String baseTypeName = null;
+                        if (type.isSimpleType())
+                            baseTypeName = CUtils.getclass4qname (type.getBaseType ());
+                        else
+                            baseTypeName = typeName;
+
+                        String elementName = attribs[i].getParamNameAsMember();
+                        
+                        if( isPointerType)
+                        {
+                            writer.write("\t" + typeName + "    pValue" + i + " = pIWSDZ->" +
+                                    CUtils.getParameterGetValueMethodName(baseTypeName, attribs[i].isAttribute()) +
+                                    "( \"" + soapTagName + "\", 0);\n\n");
+                        }
+                        else
+                        {
+                            writer.write("\t\t\t" + typeName + " *    pValue" + i + " = pIWSDZ->" +
+                                    CUtils.getParameterGetValueMethodName(baseTypeName, attribs[i].isAttribute()) +
+                                    "( \"" + soapTagName + "\", 0);\n\n");
+                        }
+                        
+                        writer.write( "\t\t\tif( pValue" + i + " == NULL)\n");
+                        writer.write( "\t\t\t{\n");
+                        writer.write("\t\t\t\tparam->" + elementName + " = NULL;\n");
+                        writer.write( "\t\t\t}\n");
+                        writer.write( "\t\t\telse\n");
+                        writer.write( "\t\t\t{\n");
+                        
+                        String localElemName = elementName;
+                        if( elementName.endsWith( "_"))
+                            localElemName = elementName.substring( 0, elementName.length() - 1);
+                        
+                        writer.write("\t\t\t\tparam->set" + localElemName + " (pValue" + i + ");\n");
+                        writer.write("\t\t\t\tAxis::AxisDelete( (void *) pValue" + i + ", " 
+                                + CUtils.getXSDTypeForBasicType( baseTypeName) + ");\n\n");
+                        writer.write( "\t\t\t}\n");
+                    }
+                } 
+                else if (attribs[i].getChoiceElement() || attribs[i].getAllElement())
+                {
+                    writer.write("\tparam->"
+                            + attribs[i].getParamNameAsMember() + " = pIWSDZ->"
+                            + CUtils.getParameterGetValueMethodName(
+                                    attribs[i].getTypeName(), attribs[i].isAttribute()) + "( \""
+                            + soapTagName + "\",0);\n");
+                }
+                else
+                {
+                    String elementNameToSearchFor = attribs[i].isAttribute()? attribs[i].getParamNameAsMember():attribs[i].getSOAPElementNameAsString();
+                    
+                    writer.write("\t" + attribs[i].getTypeName() + " * "
+                            + attribs[i].getParamNameAsMember() + " = NULL;\n\n");
+                    writer.write("\tif ((" + attribs[i].getParamNameAsMember() + " = pIWSDZ->"
+                            + CUtils.getParameterGetValueMethodName(
+                                    attribs[i].getTypeName(), attribs[i].isAttribute()) + "( \""
+                            + elementNameToSearchFor + "\",0)) != NULL)\n\t{\n");
+                    
+                    String localElemName = attribs[i].getParamNameAsMember();
+                    if( localElemName.endsWith( "_"))
+                        localElemName = localElemName.substring( 0, localElemName.length() - 1);
+
+                    writer.write("\t\tparam->set"
+                            + localElemName + "(* " + attribs[i].getParamNameAsMember() + " );\n");
+                    writer.write("\t\tAxis::AxisDelete( (void *) " + attribs[i].getParamNameAsMember() + ", " + CUtils.getXSDTypeForBasicType( attribs[i].getTypeName()) + ");\n");
+                    writer.write("\t}\n");                        
+                }
+                
+                if (attribs[i].isOptional())
+                {
+                    writer.write("\t\t\t}\n");
+                    writer.write("\t\telse\n");
+                    writer.write("\t\t{\n");
+                    writer.write("\t\t\tparam->" + attribs[i].getParamNameAsMember() + " = NULL;\n");
+                    writer.write("\t\t}\n\n");
+                }
+            }
+            else
+            {
+                //if complex type
+                //remove _Ref sufix and _ prefix in SOAP tag name
+                String soapTagName = attribs[i].getParamName();
+
+                if (soapTagName.lastIndexOf("_Ref") > -1)
+                    soapTagName = soapTagName.substring(0, soapTagName.lastIndexOf("_Ref"));
+
+                if (soapTagName.charAt(0) == '_')
+                    soapTagName = soapTagName.substring(1, soapTagName.length());
+                
+                if (attribs[i].isOptional())
+                {
+                    writer.write("\tconst char* elementName" + i + " = pIWSDZ->peekNextElementName();\n");
+                    writer.write("\tif(strcmp(elementName" + i + ", \"" + soapTagName + "\") == 0)\n");
+                    writer.write("\t{\n");
+                }
+
+                writer.write("\tparam->" + attribs[i].getParamNameAsMember()
+                        + " = (" + attribs[i].getTypeName()
+                        + "*)pIWSDZ->getCmplxObject((void*)Axis_DeSerialize_"
+                        + attribs[i].getTypeName()
+                        + "\n\t\t, (void*)Axis_Create_"
+                        + attribs[i].getTypeName() + ", (void*)Axis_Delete_"
+                        + attribs[i].getTypeName() + "\n\t\t, \"" + soapTagName
+                        + "\", Axis_URI_" + attribs[i].getTypeName() + ");\n");
+                
+                if (attribs[i].isOptional())
+                {
+                    writer.write("\t}\n");
+                    writer.write("\telse\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\tparam->" + attribs[i].getParamNameAsMember() + " = NULL;\n");
+                    writer.write("\t}\n\n");
+                }
+            }
 
-	private void writeCreateGlobalMethod() throws IOException 
+            if (attribs[i].getChoiceElement())
+                writer.write("\t}\n");
+            
+            if (attribs[i].getAllElement())
+                if (attribs[i].getMinOccurs() == 0)
+                    writer.write("\t}\n");
+        }
+
+        if (extensionBaseAttrib != null
+                && extensionBaseAttrib.getTypeName() != null)
+        {
+            writer.write("\tpIWSDZ->getChardataAs((void*)&(param->"
+                    + extensionBaseAttrib.getParamNameAsMember() + "), "
+                    + CUtils.getXSDTypeForBasicType(extensionBaseAttrib.getTypeName()) + ");\n");
+        }
+
+        writer.write("\treturn pIWSDZ->getStatus();\n");
+        writer.write("}\n");
+    }
+
+    private void writeCreateGlobalMethod() throws IOException
     {
-		writer.write("void * Axis_Create_" + classname + "( " + classname
-				+ " * pObj, bool bArray = false, int nSize = 0)\n{\n");
-		writer.write("\tif( bArray && (nSize > 0))\n\t{\n\t\tif( pObj)\n\t\t{\n");
-		writer.write("\t\t\t" + classname + " * pNew = new " + classname
-				+ "[nSize];\n\n");
-		
-        writer.write("\t\t\tsize_t i = nSize / 2;\n\n");
-        writer.write("\t\t\tfor( int ii = 0; ii < (int) i; ++ii)\n");
+        writer.write("void* Axis_Create_" + classname + "(" + classname
+                + "* pObj, bool bArray = false, int nSize=0)\n{\n");
+        writer.write("\tif (bArray && (nSize > 0))\n\t{\n\t\tif (pObj)\n\t\t{\n");
+        writer.write("\t\t\t" + classname + "* pNew = new " + classname + "[nSize];\n");
+
+        writer.write("\t\t\tsize_t i = nSize/2;\n");
+        writer.write("\t\t\tfor (int ii = 0; ii < (int) i; ++ii)\n"); 
         writer.write("\t\t\t{\n");
         writer.write("\t\t\t\tpNew[ii] = pObj[ii];\n");
         writer.write("\t\t\t\tpObj[ii].reset();\n");
-        writer.write("\t\t\t}\n\n");
+        writer.write("\t\t\t}\n");
 
-        writer.write("\t\t\tdelete [] pObj;\n\n");
-        
-		writer.write("\t\t\treturn pNew;\n\t\t}\n\t\telse\n\t\t{\n");
-		writer.write("\t\t\treturn new " + classname
-						+ "[nSize];\n\t\t}\n\t}\n");
-		writer.write("\telse\n\t{\n\t\treturn new " + classname + ";\n\t}\n}\n\n");
-	}
+        writer.write("\t\t\tdelete [] pObj;\n");
+        writer.write("\t\t\treturn pNew;\n\t\t}\n\t\telse\n\t\t{\n");
+        writer.write("\t\t\treturn new " + classname + "[nSize];\n\t\t}\n\t}\n");
+        writer.write("\telse\n\t\treturn new " + classname + ";\n}\n\n");
+    }
 
-	private void writeDeleteGlobalMethod() throws IOException 
+    private void writeDeleteGlobalMethod() throws IOException
     {
         writer.write("/*\n");
-        writer.write(" * This static method delete a " + classname
-                + " type of object\n");
+        writer.write(" * This static method delete a " + classname + " type of object\n");
         writer.write(" */\n");
         writer.write("void Axis_Delete_" + classname + "(" + classname
                 + "* param, bool bArray = false, int nSize=0)\n");
@@ -817,142 +1174,367 @@
         writer.write("}\n");
     }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
-	 */
-	protected void writeConstructors() throws WrapperFault 
-    {
-		try 
-        {
-			writer.write("\n" + classname + "::" + classname + "()\n{\n");
-			for (int i = 0 ; i < attribs.length ; i++)
-			{
-			    if (attribs[i].isArray())
-			    {
-			        writer.write("\t" + attribs[i].getParamNameAsMember() + " = NULL;\n");
-			    }
-			}
-            writer.write("\t reset();\n");
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
+     */
+    protected void writeConstructors() throws WrapperFault
+    {
+        try
+        {
+            // Write default constructor
+            writer.write("\n" + classname + "::" + classname + "()\n{\n");
+            for (int i = 0 ; i < attribs.length ; i++)
+            {
+                if (attribs[i].isArray())
+                {
+                    if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
+                    {
+                        // This is the 'choice' or 'all' route in the code
+                        writer.write("\t\t// This object is a 'choice' or 'all', so need to ensure that any\n");
+                        writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
+                        writer.write("\t\t// NB: Hasn't been implemented yet!\n");
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + " = new " 
+                                + attribs[i].getTypeName() +"_Array();\n");
+                    }
+                    else
+                    {
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + " = new " 
+                                + attribs[i].getTypeName() +"_Array();\n");
+                    }
+                }
+            }
+            writer.write("\treset();\n");
             writer.write("}\n");
 
-            writeReset(); 
-		} 
-        catch (IOException e) 
+            writeCopyConstructor();
+            writeReset();
+        }
+        catch (IOException e)
         {
-			throw new WrapperFault(e);
-		}
-	}
+            throw new WrapperFault(e);
+        }
+    }
     
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see 
-	 */
-	protected void writeReset() throws WrapperFault 
-    {
-		try 
-        {
-			writer.write("\nvoid " + classname + "::reset()\n{\n");
-			writer.write("\t/*do not allocate memory to any pointer members here\n\t because deserializer will allocate memory anyway. */\n");
-			
-			int anyCounter = 0;
-			
-			for (int i = 0; i < attribs.length; i++) 
-            {
-				if (attribs[i].isArray()) 
-                {
-                    writer.write("\tif ( " + attribs[i].getParamNameAsMember() + " != NULL)\n");
-                    writer.write("\t{\n");
-                    writer.write("\t\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
-                    writer.write("\t}\n");
-				} 
-                else if (!attribs[i].isSimpleType()) 
-                {
-					if (attribs[i].isAnyType())
-                    {
-                    	anyCounter += 1;
-                    	writer.write("\t" + attribs[i].getParamNameAsMember() + Integer.toString(anyCounter)
-                                + "= 0;\n");
-                    }
-                	else
-                    {				
-                		writer.write("\t" + attribs[i].getParamNameAsMember()
-							+ " = 0;\n");
-                	}
-				}
-				// FJP Nillable vv
-				else if (isElementNillable(i)) 
-                {
-					writer.write("\t" + attribs[i].getParamNameAsMember()
-							+ " = NULL;\n");
-				}
-				// FJP Nillable ^^
-				else 
-                {
-					/* Needed for shared libraries */
-				    if(CUtils.isPointerType(attribs[i].getTypeName()))
-				    {
-					writer.write("\t"+attribs[i].getParamNameAsMember()+"=0;\n");
-				    }
-				}
-			}
-			writer.write("}\n");
-		} 
-        catch (IOException e) 
+    /**
+     * @throws IOException
+     */
+    private void writeCopyConstructor() throws WrapperFault
+    {
+        try
         {
-			throw new WrapperFault(e);
-		}
-	}
+            //write copy constructor
+            writer.write("\n" + classname + "::" + classname + "(const " + classname + " & original)\n{\n");
+            int anyCounter = 0;
+            for (int i = 0 ; i < attribs.length ; i++)
+            {
+                if (attribs[i].isArray())
+                {    
+                    if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
+                    {
+                        // This is the 'choice' or 'all' route in the code
+                        writer.write("\t\t// This object is a 'choice' or 'all', so need to ensure that any\n");
+                        writer.write("\t\t// other objects belonging to this union of elements are empty.\n");
+                        writer.write("\t\t// NB: Hasn't been implemented yet!\n");
+                        writer.write("\t" + attribs[i].getParamName() + " = new " 
+                                + attribs[i].getTypeName() + "_Array( *original." 
+                                + attribs[i].getParamName() + ");\n");
+                    }
+                    else
+                    {
+                        writer.write("\t" + attribs[i].getParamName() + " = new " 
+                                + attribs[i].getTypeName() + "_Array(*original." 
+                                + attribs[i].getParamName() + ");\n");
+                    }
+                }
+                else if (attribs[i].isAnyType())
+                {
+                    anyCounter++;
+                    writer.write("\tif (original." + attribs[i].getParamName() + anyCounter + " != NULL)\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\t" + attribs[i].getParamName() + anyCounter + " = new " + attribs[i].getTypeName() + "(*(original." + attribs[i].getParamName() + anyCounter + "));\n");
+                    writer.write("\t}\n");
+                    writer.write("\telse\n");
+                    writer.write("\t{\n");
+                    writer.write("\t\t" + attribs[i].getParamName() + anyCounter + " = NULL;\n");
+                    writer.write("\t}\n");
+                }
+                else
+                {
+                    Type type = attribs[i].getType();
+                    boolean isPointerType = false;
+                    if (type.isSimpleType())
+                        isPointerType = CUtils.isPointerType(CUtils.getclass4qname(type.getBaseType())); 
+                    else
+                        isPointerType = CUtils.isPointerType(attribs[i].getTypeName());
+    
+                    if ((attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()) && (isPointerType || attribs[i].isOptional() || attribs[i].isNillable() || attribs[i].getChoiceElement() || attribs[i].getAllElement()))
+                    {
+                        writer.write("\t" + attribs[i].getParamName() + " = NULL;\n");
+                        writer.write("\t__axis_deepcopy_" + attribs[i].getParamName() + " = false;\n");
+                        String methodName = attribs[i].getParamNameWithoutSymbols();
+                        if( methodName.endsWith( "_"))
+                        {
+                            String localMethodName = methodName.substring( 0, methodName.length() - 1);
+                            
+                            if( localMethodName.equals( classname))
+                                methodName = localMethodName; 
+                        }
+                        writer.write("\tset" + methodName + "(original." + attribs[i].getParamName() + ", original.__axis_deepcopy_" + attribs[i].getParamName() + ");\n\n");
+                    }
+                    else if (attribs[i].isSimpleType())
+                    {
+                        writer.write("\t" + attribs[i].getParamName() + " = original." 
+                                + attribs[i].getParamName() + ";\n");
+                    }
+                    else
+                    {
+                        writer.write("\tif (original." + attribs[i].getParamName() + " != NULL)\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\t" + attribs[i].getParamName() + " = new " 
+                                + attribs[i].getTypeName() + "(*(original." 
+                                + attribs[i].getParamName() + "));\n");
+                        writer.write("\t}\n");
+                        writer.write("\telse\n");
+                        writer.write("\t{\n");
+                        writer.write("\t\t" + attribs[i].getParamName() + " = NULL;\n");
+                        writer.write("\t}\n");
+                    }
+                }
+            }
+            writer.write("}\n");
+        }
+        catch (IOException e)
+        {
+            throw new WrapperFault(e);
+        }
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeDistructors()
-	 */
-	protected void writeDestructors() throws WrapperFault 
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     */
+    protected void writeReset() throws WrapperFault
     {
-		try 
+        try
         {
-			if (type.isFault())
+            writer.write("\nvoid " + classname + "::reset()\n{\n");
+            writer.write("\t/*do not allocate memory to any pointer members here\n\t because deserializer will allocate memory anyway. */\n");
+            
+            int anyCounter = 0;
+
+            for (int i = 0; i < attribs.length; i++)
             {
-                writer.write("\n" + classname + "::~" + classname
-                        + "() throw ()\n{\n");
+                if (attribs[i].isArray())
+                {
+                    if (attribs[i].getChoiceElement()||attribs[i].getAllElement())
+                    {
+                        writer.write( "\t// This object is a 'choice' or 'all', so need to ensure that any\n");
+                        writer.write( "\t// other objects belonging to this union of elements are empty.\n");
+                        writer.write( "\t// NB: Hasn't been implemented yet!\n");
+
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
+                    }
+                    else
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + "->clear();\n");
+                }
+                else if (!(attribs[i].isSimpleType() || attribs[i].getType().isSimpleType()))
+                {
+                    if (attribs[i].isAnyType())
+                    {
+                        anyCounter += 1;
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + Integer.toString(anyCounter)
+                                + "= NULL;\n");
+                    }
+                    else
+                        writer.write("\t" + attribs[i].getParamNameAsMember() + "= NULL;\n");
+                }

[... 219 lines stripped ...]


Mime
View raw message