axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From susan...@apache.org
Subject cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info TypeMap.java
Date Thu, 02 Oct 2003 08:45:23 GMT
susantha    2003/10/02 01:45:23

  Modified:    c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c
                        BeanParamWriter.java ParmHeaderFileWriter.java
                        WrapWriter.java
               c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp
                        BeanParamWriter.java ClientStubWriter.java
                        ParmHeaderFileWriter.java WrapWriter.java
               c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info TypeMap.java
  Removed:     c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c
                        ClientStubWriter.java
  Log:
  Improved WSDL2WS tool to generate stubs to invoke web service methods that are passed and
returned arrrays
  Also fixed few bugs http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23555
  
  Revision  Changes    Path
  1.3       +7 -0      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java
  
  Index: BeanParamWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/BeanParamWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BeanParamWriter.java	29 Sep 2003 04:10:43 -0000	1.2
  +++ BeanParamWriter.java	2 Oct 2003 08:45:22 -0000	1.3
  @@ -81,6 +81,7 @@
   		writer.write("static const AxisChar* Axis_TypeName_"+classname+" = \""+type.getName().getLocalPart()+"\";\n\n");
   		writeSerializeGlobalMethod();
   		writeDeSerializeGlobalMethod();
  +		writeCreateGlobalMethod();
   		writeDeleteGlobalMethod();
   		writeGetSizeGlobalMethod();
   		}catch(IOException e){
  @@ -181,6 +182,12 @@
   		}
   		writer.write("\treturn SUCCESS;\n");
   		writer.write("}\n");
  +	}
  +	
  +	private void writeCreateGlobalMethod()throws IOException{
  +		writer.write("void* Axis_Create_"+classname+"(bool bArray = false, int nSize=0)\n{\n");
  +		writer.write("\tif (bArray && (nSize > 0))\n\t\treturn new "+classname+"[nSize];\n");
  +		writer.write("\telse\n\t\treturn new "+classname+";\n}\n\n");	
   	}
   	
   	private void writeDeleteGlobalMethod()throws IOException{
  
  
  
  1.2       +7 -10     ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java
  
  Index: ParmHeaderFileWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ParmHeaderFileWriter.java	19 Sep 2003 14:25:50 -0000	1.1
  +++ ParmHeaderFileWriter.java	2 Oct 2003 08:45:22 -0000	1.2
  @@ -87,6 +87,7 @@
   			this.writer.write("typedef struct {\n");
   			writeAttributes();
   			this.writer.write("} "+classname+";\n\n");
  +			writeArrayStruct();
   			//writeConstructors();
   			//writeDistructors();
   			//writeMethods();
  @@ -113,22 +114,18 @@
   		  }
   	  }
   	  
  -	protected void writeConstructors()throws WrapperFault{
  -		   try{
  -			 writer.write("public:\n\t"+classname+"::" + classname + "();\n");
  -		   } catch (IOException e) {
  -				throw new WrapperFault(e);
  -		   }
  -	   }
  +	protected void writeConstructors()throws WrapperFault{}
   	   
  -	protected void writeDistructors() throws WrapperFault {
  +	protected void writeDistructors() throws WrapperFault {}
  +	
  +	protected void writeArrayStruct()throws WrapperFault{
   		try{
  -		  writer.write("public:\n\t"+classname+"::~" + classname + "();\n");
  +			writer.write("typedef struct Axis_"+classname+"_ArrayTag\n{\n");
  +			writer.write("\t"+classname+"* m_Array;\n\tint m_Size;\n} Axis_"+classname+"_Array;\n\n");
   		} catch (IOException e) {
   			 throw new WrapperFault(e);
   		}
   	}
  -   
   	   
   	protected void writeMethods()throws WrapperFault{}
   
  
  
  
  1.3       +2 -1      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapWriter.java
  
  Index: WrapWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WrapWriter.java	26 Sep 2003 04:34:44 -0000	1.2
  +++ WrapWriter.java	2 Oct 2003 08:45:23 -0000	1.3
  @@ -188,7 +188,7 @@
   		if (methods.size() > 1) {
   			for (int i = 1; i < methods.size(); i++) {
   				minfo = (MethodInfo)methods.get(i);
  -				writer.write("\telse if (0 == strcmp(method, \""+ minfo.getMethodname() +"\")\n");
  +				writer.write("\telse if (0 == strcmp(method, \""+ minfo.getMethodname() +"\"))\n");
   				writer.write("\t\treturn "+minfo.getMethodname()+CUtils.WRAPPER_METHOD_APPENDER+"(mc);\n");
   			}
   		}
  @@ -330,6 +330,7 @@
   			while(types.hasNext()){
   				typeName = ((Type)types.next()).getLanguageSpecificName();
   				writer.write("extern int Axis_DeSerialize_"+typeName+"("+typeName+"* param, IWrapperSoapDeSerializer
*pDZ);\n");
  +				writer.write("extern void* Axis_Create_"+typeName+"(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+"("+typeName+"* param);\n\n");
  
  
  
  1.3       +7 -0      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java
  
  Index: BeanParamWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/BeanParamWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BeanParamWriter.java	29 Sep 2003 04:10:43 -0000	1.2
  +++ BeanParamWriter.java	2 Oct 2003 08:45:23 -0000	1.3
  @@ -86,6 +86,7 @@
   		writer.write("static const AxisChar* Axis_TypeName_"+classname+" = \""+type.getName().getLocalPart()+"\";\n\n");
   		writeSerializeGlobalMethod();
   		writeDeSerializeGlobalMethod();
  +		writeCreateGlobalMethod();
   		writeDeleteGlobalMethod();
   		writeGetSizeGlobalMethod();
   		}catch(IOException e){
  @@ -176,6 +177,12 @@
   		}
   		writer.write("\treturn SUCCESS;\n");
   		writer.write("}\n");
  +	}
  +	
  +	private void writeCreateGlobalMethod()throws IOException{
  +		writer.write("void* Axis_Create_"+classname+"(bool bArray = false, int nSize=0)\n{\n");
  +		writer.write("\tif (bArray && (nSize > 0))\n\t\treturn new "+classname+"[nSize];\n");
  +		writer.write("\telse\n\t\treturn new "+classname+";\n}\n\n");	
   	}
   	
   	private void writeDeleteGlobalMethod()throws IOException{
  
  
  
  1.5       +61 -27    ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java
  
  Index: ClientStubWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClientStubWriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ClientStubWriter.java	26 Sep 2003 04:34:44 -0000	1.4
  +++ ClientStubWriter.java	2 Oct 2003 08:45:23 -0000	1.5
  @@ -172,66 +172,99 @@
   	 */
   
   	public void writeMethodInWrapper(String methodName, Collection params, ParameterInfo returntype)
throws WrapperFault,IOException {
  -		String outparam = returntype.getLangName();
  +		String outparamType = returntype.getLangName();
  +		boolean returntypeiscomplex = !CPPUtils.isSimpleType(outparamType);
  +		boolean returntypeisarray = returntype.getType().isArray();
   		writer.write("\n/////////////////////////////////////////////////////////////////\n");
   		writer.write("// This method wrap the service method"+ methodName +"\n");
   		writer.write("//////////////////////////////////////////////////////////////////\n");
   		//method signature
   		String paraTypeName;
   		Type type;
  +		if (returntypeisarray){
  +			writer.write("Axis_"+outparamType+"_Array");	
  +		}else{
  +			writer.write(outparamType+(returntypeiscomplex?"*":""));
  +		}
  +		writer.write(" "+classname+"::" + methodName + "(");
   		ArrayList paramsB = (ArrayList)params;
  -		writer.write(outparam + " "+classname+"::" + methodName + "(");
   		if (0 < paramsB.size()){
   			paraTypeName = ((ParameterInfo)paramsB.get(0)).getLangName();
  -			writer.write(paraTypeName + (CPPUtils.isSimpleType(paraTypeName) ? " Value0":"* pValue0"));
  +			if(((ParameterInfo)paramsB.get(0)).getType().isArray()){
  +				writer.write("Axis_"+paraTypeName+"_Array Value0");
  +			}else{
  +				writer.write(paraTypeName + (CPPUtils.isSimpleType(paraTypeName) ? " Value0":"* pValue0"));
  +			}
   			for (int i = 1; i < paramsB.size(); i++) {
   				paraTypeName = ((ParameterInfo)paramsB.get(i)).getLangName();
  -				writer.write(", "+paraTypeName + (CPPUtils.isSimpleType(paraTypeName) ? " Value":"*
pValue")+i);
  +				if(((ParameterInfo)paramsB.get(i)).getType().isArray()){
  +					writer.write(", Axis_"+paraTypeName+"_Array Value"+i);
  +				}else{
  +					writer.write(", "+paraTypeName + (CPPUtils.isSimpleType(paraTypeName) ? " Value":"*
pValue")+i);
  +				}
   			}
   		}
   		writer.write(")\n{\n");
  -		writer.write("\tint nStatus;\n");
  -		writer.write("\tif (SUCCESS != m_pCall->Initialize())\n\t");
  -		writer.write("\treturn "+ (CPPUtils.isSimpleType(outparam)?"0":"NULL") +";\n");
  -		//TODO handle returning appropriate type in case of string, char* and struct tm.
  +		writer.write("\tint nStatus;\n\t");
  +		if(returntypeisarray){
  +			//for arrays
  +			writer.write("Axis_"+outparamType+"_Array RetArray = {NULL, 0};\n");
  +		}else if(returntypeiscomplex){
  +			writer.write(outparamType+"* pReturn = NULL;\n");
  +			//for complex types
  +		}else{
  +			//for simple types
  +			writer.write(outparamType+" Ret;\n");
  +			//TODO initialize return parameter appropriately.
  +		}
  +		writer.write("\tif (SUCCESS != m_pCall->Initialize()) return ");
  +		writer.write((returntypeisarray?"RetArray":returntypeiscomplex?"pReturn":"Ret")+";\n\t");
  +		writer.write("m_pCall->SetSOAPVersion(SOAP_VER_1_2);\n"); //TODO check which version
is it really.
   		writer.write("\tm_pCall->SetOperation(\""+methodName+"\", \""+ wscontext.getWrapInfo().getTargetNameSpaceOfWSDL()
+"\");\n");
   		for (int i = 0; i < paramsB.size(); i++) {
   			paraTypeName = ((ParameterInfo)paramsB.get(i)).getLangName();
   			writer.write("\tm_pCall->AddParameter(");			
  +			if(((ParameterInfo)paramsB.get(i)).getType().isArray()){
  +				//arrays
  +				writer.write("(Axis_Array*)(&Value"+i+"), (void*)Axis_Serialize_"+paraTypeName+",
(void*)Axis_Delete_"+paraTypeName+", (void*) Axis_GetSize_"+paraTypeName+", Axis_TypeName_"+paraTypeName);
  +			}
   			if(CPPUtils.isSimpleType(paraTypeName)){
   				//for simple types	
   				writer.write("Value"+i+", \"" + ((ParameterInfo)paramsB.get(i)).getParamName()+"\"");
  -			//}else if((type = this.wscontext.getTypemap().getType(((ParameterInfo)paramsB.get(i)).getSchemaName()))
!= null 
  -			//			&& type.isArray()){
  -				//TODO for Array types				
  -				//String ContentparaTypeName = WrapperUtils.getParameterName4ParamInfo((ParameterInfo)paramsB.get(i),wscontext);
  -			
   			}else{
   				//for complex types 
   				writer.write("pValue"+i+", Axis_Serialize_"+paraTypeName+", Axis_Delete_"+paraTypeName+",
\"" + ((ParameterInfo)paramsB.get(i)).getParamName()+"\"");
   			}
   			writer.write(");\n");
  +			//}else if((type = this.wscontext.getTypemap().getType(((ParameterInfo)paramsB.get(i)).getSchemaName()))
!= null 
  +			//			&& type.isArray()){
   		}
  -		if (CPPUtils.isSimpleType(outparam)){
  -			writer.write("\t"+outparam+" RetValue;\n");
  -			writer.write("\tm_pCall->SetReturnType(XSD_UNKNOWN);\n");
  +		if (returntypeisarray){
  +			writer.write("\tm_pCall->SetReturnType((Axis_Array*)(&RetArray), (void*) Axis_DeSerialize_"+outparamType);
  +			writer.write(", (void*) Axis_Create_"+outparamType+", (void*) Axis_Delete_"+outparamType+",
Axis_TypeName_"+outparamType+", Axis_URI_"+outparamType+");\n");
  +			writer.write("\tnStatus = m_pCall->Invoke();\n");
  +			writer.write("\tif (SUCCESS != nStatus)\n\t{\n");
  +			writer.write("\t\tdelete RetArray.m_Array;\n");
  +			writer.write("\t\tRetArray.m_Array = NULL;\n");
  +			writer.write("\t\tRetArray.m_Size = 0;\n}\n");
  +			writer.write("\tm_pCall->UnInitialize();\n");
  +			writer.write("\treturn RetArray;\n");
  +		}
  +		else if(returntypeiscomplex){
  +			writer.write("\tm_pCall->SetReturnType((void*) Axis_DeSerialize_"+outparamType+",
(void*) Axis_Create_"+outparamType+", (void*) Axis_Delete_"+outparamType+", Axis_TypeName_"+outparamType+",
Axis_URI_"+outparamType+");\n");
   			writer.write("\tnStatus = m_pCall->Invoke();\n");
   			writer.write("\tif (SUCCESS == nStatus)\n\t{\n");
  -			writer.write("\t\tRetValue = m_pCall->GetResult()."+CPPUtils.getUnionMemberForBasicType(outparam)+";\n\t}\n");
  +			writer.write("\t\tm_pCall->GetResult((void**)&pReturn);\n\t}\n");
   			writer.write("\tm_pCall->UnInitialize();\n");
  -			writer.write("\treturn RetValue;\n");
  +			writer.write("\treturn pReturn;\n");			
   		}
  -		//else if (){
  -		//TODO handle if return type is array type
  -		//}
   		else{
  -			writer.write("\t"+outparam+"* pRetValue = new "+outparam+ "();\n");
  -			writer.write("\tm_pCall->SetReturnType(pRetValue, Axis_DeSerialize_"+outparam+",
Axis_Delete_"+outparam+", Axis_TypeName_"+outparam+", Axis_URI_"+outparam+");\n");
  +			writer.write("\tm_pCall->SetReturnType(XSD_UNKNOWN);\n");
   			writer.write("\tnStatus = m_pCall->Invoke();\n");
  -			writer.write("\tif (SUCCESS != nStatus)\n\t{\n");
  -			writer.write("\t\tdelete pRetValue;\n\t\tpRetValue = NULL;\n\t}\n");
  +			writer.write("\tif (SUCCESS == nStatus)\n\t{\n");
  +			writer.write("\t\tRet = m_pCall->GetResult()."+CPPUtils.getUnionMemberForBasicType(outparamType)+";\n\t}\n");
   			writer.write("\tm_pCall->UnInitialize();\n");
  -			writer.write("\treturn pRetValue;\n");			
  +			writer.write("\treturn Ret;\n");
   		}
   
   	//write end of method
  @@ -247,12 +280,13 @@
   			while(types.hasNext()){
   				typeName = ((Type)types.next()).getLanguageSpecificName();
   				writer.write("extern int Axis_DeSerialize_"+typeName+"("+typeName+"* param, IWrapperSoapDeSerializer
*pDZ);\n");
  +				writer.write("extern void* Axis_Create_"+typeName+"(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+"("+typeName+"* param);\n\n");
   				//Local name and the URI for the type
   				writer.write("//Local name and the URI for the type\n");
  -				writer.write("static const AxisChar* Axis_URI_"+typeName+" = " + "\"http://www.opensource.lk/"
+ typeName + "\"\n");
  +				writer.write("static const AxisChar* Axis_URI_"+typeName+" = " + "\"http://www.opensource.lk/"
+ typeName + "\";\n");
   				writer.write("static const AxisChar* Axis_TypeName_"+typeName+" = \"" +typeName+"\";\n\n");
   			}
   		} catch (IOException e) {
  
  
  
  1.3       +12 -15    ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java
  
  Index: ParmHeaderFileWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ParmHeaderFileWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ParmHeaderFileWriter.java	25 Sep 2003 04:40:45 -0000	1.2
  +++ ParmHeaderFileWriter.java	2 Oct 2003 08:45:23 -0000	1.3
  @@ -87,6 +87,7 @@
   			this.writer.write("class "+classname+"\n{\n");
   			writeAttributes();
   			this.writer.write("};\n\n");
  +			writeArrayStruct();
   			//writeConstructors();
   			//writeDistructors();
   			//writeMethods();
  @@ -101,6 +102,15 @@
   		}
   	}
   
  +	protected void writeArrayStruct()throws WrapperFault{
  +		try{
  +			writer.write("typedef struct Axis_"+classname+"_ArrayTag\n{\n");
  +			writer.write("\t"+classname+"* m_Array;\n\tint m_Size;\n} Axis_"+classname+"_Array;\n\n");
  +		} catch (IOException e) {
  +			 throw new WrapperFault(e);
  +		}
  +	}
  +	
   	protected void writeAttributes()throws WrapperFault{
   		  if(type.isArray()) return;
   		  try{
  @@ -114,23 +124,10 @@
   		  }
   	  }
   	  
  -	protected void writeConstructors()throws WrapperFault{
  -		   try{
  -			 writer.write("public:\n\t"+classname+"::" + classname + "();\n");
  -		   } catch (IOException e) {
  -				throw new WrapperFault(e);
  -		   }
  -	   }
  +	protected void writeConstructors()throws WrapperFault{}
   	   
  -	protected void writeDistructors() throws WrapperFault {
  -		try{
  -		  writer.write("public:\n\t"+classname+"::~" + classname + "();\n");
  -		} catch (IOException e) {
  -			 throw new WrapperFault(e);
  -		}
  -	}
  +	protected void writeDistructors() throws WrapperFault {}
      
  -	   
   	protected void writeMethods()throws WrapperFault{}
   
   	protected File getFilePath() throws WrapperFault {
  
  
  
  1.3       +2 -1      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java
  
  Index: WrapWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/WrapWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WrapWriter.java	26 Sep 2003 04:34:44 -0000	1.2
  +++ WrapWriter.java	2 Oct 2003 08:45:23 -0000	1.3
  @@ -189,7 +189,7 @@
   		if (methods.size() > 1) {
   			for (int i = 1; i < methods.size(); i++) {
   				minfo = (MethodInfo)methods.get(i);
  -				writer.write("\telse if (0 == strcmp(method, \""+ minfo.getMethodname() +"\")\n");
  +				writer.write("\telse if (0 == strcmp(method, \""+ minfo.getMethodname() +"\"))\n");
   				writer.write("\t\treturn "+minfo.getMethodname()+"(mc);\n");
   			}
   		}
  @@ -311,6 +311,7 @@
   			while(types.hasNext()){
   				typeName = ((Type)types.next()).getLanguageSpecificName();
   				writer.write("extern int Axis_DeSerialize_"+typeName+"("+typeName+"* param, IWrapperSoapDeSerializer
*pDZ);\n");
  +				writer.write("extern void* Axis_Create_"+typeName+"(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+"("+typeName+"* param);\n\n");
  
  
  
  1.2       +1 -2      ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java
  
  Index: TypeMap.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/TypeMap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TypeMap.java	19 Sep 2003 14:25:51 -0000	1.1
  +++ TypeMap.java	2 Oct 2003 08:45:23 -0000	1.2
  @@ -198,8 +198,7 @@
       /* get all the custom types in the typeMap */
       public Collection getTypes() {
           return this.typeInfo.values();
  -    }
  -	
  +    } 
   	
      /**
        * The wsdl support the attributes names that are not allowed by the program langage.
  
  
  

Mime
View raw message