| /* |
| * Copyright 2003-2004 The Apache Software Foundation. |
| // (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package org.apache.axis.wsdl.wsdl2ws.c; |
| |
| import java.io.IOException; |
| import java.util.ArrayList; |
| import java.util.Collection; |
| import java.util.Iterator; |
| |
| import javax.xml.namespace.QName; |
| |
| import org.apache.axis.wsdl.wsdl2ws.CUtils; |
| import org.apache.axis.wsdl.wsdl2ws.WrapperFault; |
| import org.apache.axis.wsdl.wsdl2ws.info.FaultInfo; |
| import org.apache.axis.wsdl.wsdl2ws.info.MethodInfo; |
| import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo; |
| import org.apache.axis.wsdl.wsdl2ws.info.Type; |
| import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext; |
| |
| public class ClientStubWriter extends CFileWriter |
| { |
| protected ArrayList methods; |
| |
| /** |
| * @param wscontext |
| * @throws WrapperFault |
| */ |
| public ClientStubWriter(WebServiceContext wscontext) throws WrapperFault |
| { |
| super(wscontext.getServiceInfo().getServicename()); |
| this.wscontext = wscontext; |
| this.methods = wscontext.getServiceInfo().getMethods(); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeClassComment() |
| */ |
| protected void writeClassComment() throws WrapperFault |
| { |
| try |
| { |
| c_writer.write("/*\n"); |
| c_writer.write(" * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)\n"); |
| c_writer.write(" * This file contains Client Stub implementation for remote web service.\n"); |
| c_writer.write(" */\n\n"); |
| } |
| catch (IOException e) |
| { |
| throw new WrapperFault(e); |
| } |
| } |
| /* |
| * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods() |
| * Used by literal code too! |
| */ |
| protected void writeMethods() throws WrapperFault |
| { |
| try |
| { |
| // get_xxx_stub() routine |
| CUtils.printMethodComment(c_writer, "Function to get new object representing a Web service stub."); |
| |
| c_writer.write("AXISCHANDLE get_" + c_classname + "_stub(const char* pchEndPointUri)\n{\n"); |
| c_writer.write("\tif(pchEndPointUri)\n"); |
| c_writer.write("\t\treturn axiscStubCreate(pchEndPointUri, AXISC_APTHTTP1_1);\n"); |
| c_writer.write("\telse\n"); |
| c_writer.write("\t\treturn axiscStubCreate(\"" |
| + wscontext.getServiceInfo().getTargetEndpointURI() |
| + "\", AXISC_APTHTTP1_1);\n"); |
| c_writer.write("}\n\n"); |
| |
| // destroy_xxxx_stub() |
| CUtils.printMethodComment(c_writer, "Function to destroy an object representing a Web service stub."); |
| |
| c_writer.write("void destroy_" + c_classname + "_stub(AXISCHANDLE p)\n{\n"); |
| c_writer.write("\taxiscStubDestroy(p);\n}\n\n"); |
| |
| // get_xxxx_Status() routine |
| CUtils.printMethodComment(c_writer, "Function to get the status of last Web service method invocation."); |
| |
| c_writer.write("int get_" + c_classname + "_Status(AXISCHANDLE stub)\n{\n"); |
| c_writer.write("\tAXISCHANDLE call = axiscStubGetCall(stub);\n"); |
| c_writer.write("\treturn axiscCallGetStatus(call);\n"); |
| c_writer.write("}\n\n"); |
| |
| CUtils.printMethodComment(c_writer, "Function to set a Web service stub's exception handler."); |
| c_writer.write("void set_" + c_classname |
| + "_ExceptionHandler(AXISCHANDLE stub, AXIS_EXCEPTION_HANDLER_FUNCT fp)\n{\n"); |
| c_writer.write("\taxiscStubSetCExceptionHandler(stub, (void *)fp);\n"); |
| c_writer.write("}\n"); |
| |
| MethodInfo minfo; |
| for (int i = 0; i < methods.size(); i++) |
| { |
| minfo = (MethodInfo) methods.get(i); |
| this.writeMethodInWrapper(minfo); |
| } |
| } |
| catch (IOException e) |
| { |
| throw new WrapperFault(e); |
| } |
| } |
| |
| /* (non-Javadoc) |
| * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements() |
| */ |
| protected void writePreprocessorStatements() throws WrapperFault |
| { |
| try |
| { |
| //writer.write("#include <stdlib.h>\n"); |
| c_writer.write("#include <stdio.h>\n"); |
| c_writer.write("#include <string.h>\n"); |
| c_writer.write("\n"); |
| |
| c_writer.write("#include \"" + CUtils.resolveWSDL2LanguageNameClashes(c_classname) + CUtils.getHeaderFileExtension() + "\"\n"); |
| c_writer.write("\n"); |
| c_writer.write("#include <axis/client/Stub.h>\n"); |
| c_writer.write("#include <axis/client/Call.h>\n"); |
| c_writer.write("#include <axis/IWrapperSoapSerializer.h>\n"); |
| c_writer.write("#include <axis/IWrapperSoapDeSerializer.h>\n"); |
| |
| c_writer.write("\n"); |
| } |
| catch (IOException e) |
| { |
| throw new WrapperFault(e); |
| } |
| } |
| |
| /** |
| * This method genarate methods that wraps the each method of the service |
| * @param minfo |
| * @throws IOException |
| */ |
| public void writeMethodInWrapper(MethodInfo minfo) throws WrapperFault, IOException |
| { |
| boolean isAllTreatedAsOutParams = false; |
| ParameterInfo returntype = null; |
| int noOfOutParams = minfo.getOutputParameterTypes().size(); |
| if (0 == noOfOutParams) |
| returntype = null; |
| else if (1 == noOfOutParams) |
| returntype = (ParameterInfo) minfo.getOutputParameterTypes().iterator().next(); |
| else |
| isAllTreatedAsOutParams = true; |
| |
| Collection params = minfo.getInputParameterTypes(); |
| |
| Type retType = null; |
| boolean returntypeissimple = false; |
| boolean returntypeisarray = false; |
| String outparamTypeName = null; |
| if (returntype != null) |
| { |
| outparamTypeName = CUtils.getClassNameFromParamInfoConsideringArrays(returntype, wscontext); |
| retType = wscontext.getTypemap().getType(returntype.getSchemaName()); |
| if (retType != null) |
| { |
| returntypeisarray = retType.isArray(); |
| |
| if (CUtils.isSimpleType(retType.getLanguageSpecificName())) |
| returntypeissimple = true; |
| } |
| } |
| |
| CUtils.printMethodComment(c_writer, "This function wraps the service method " + minfo.getMethodname() + "."); |
| |
| //method signature |
| String paramTypeName; |
| boolean typeisarray = false; |
| boolean typeissimple = false; |
| Type type; |
| if (returntype == null) |
| c_writer.write("void"); |
| else |
| { |
| if (returntypeissimple |
| && (!(returntype.isNillable() || returntype.isOptional()) |
| || CUtils.isPointerType(outparamTypeName))) |
| c_writer.write (outparamTypeName); |
| else if (outparamTypeName.lastIndexOf ("*") > 0) |
| c_writer.write (outparamTypeName); |
| else |
| c_writer.write (outparamTypeName + "*"); |
| |
| } |
| |
| c_writer.write(" " + minfo.getSanitizedMethodName() + "(AXISCHANDLE stub"); |
| ArrayList paramsB = (ArrayList) params; |
| for (int i = 0; i < paramsB.size(); i++) |
| { |
| c_writer.write(", "); |
| |
| paramTypeName = |
| CUtils.getClassNameFromParamInfoConsideringArrays((ParameterInfo) paramsB.get(i), wscontext); |
| |
| typeissimple = CUtils.isSimpleType(paramTypeName); |
| if (typeissimple |
| && (!(((ParameterInfo) paramsB.get (0)).isNillable () |
| || ((ParameterInfo) paramsB.get (0)).isOptional()) |
| || CUtils.isPointerType(paramTypeName))) |
| c_writer.write (paramTypeName + " Value" + i); |
| else if (paramTypeName.lastIndexOf ("*") > 0) |
| c_writer.write (paramTypeName + " Value" + i); |
| else |
| c_writer.write (paramTypeName + "* Value" + i); |
| } |
| |
| // Multiples parameters so fill the methods prototype |
| ArrayList paramsC = (ArrayList) minfo.getOutputParameterTypes(); |
| if (isAllTreatedAsOutParams) |
| { |
| for (int i = 0; i < paramsC.size(); i++) |
| { |
| type = wscontext.getTypemap().getType( |
| ((ParameterInfo) paramsC.get(i)).getSchemaName()); |
| c_writer.write(", AXISC_OUT_PARAM " |
| + CUtils.getClassNameFromParamInfoConsideringArrays( |
| (ParameterInfo) paramsC.get(i),wscontext) + " *OutValue" + i); |
| } |
| } |
| |
| c_writer.write(")\n{\n"); |
| |
| c_writer.write("\tAXISCHANDLE call = axiscStubGetCall(stub);\n"); |
| |
| if (returntype != null) |
| { |
| c_writer.write("\t"); |
| if (returntypeisarray) |
| { |
| QName qname = null; |
| if (CUtils.getArrayType (retType) != null) |
| qname = CUtils.getArrayType (retType).getName (); |
| else |
| qname = retType.getName (); |
| if (CUtils.isSimpleType (qname)) |
| c_writer.write(outparamTypeName + " *RetArray = (" + outparamTypeName + " *)axiscAxisNew(XSDC_ARRAY, 0);\n"); |
| else |
| c_writer.write(outparamTypeName + " *RetArray = (" + outparamTypeName + " *)Axis_Create_" + outparamTypeName + "(0);\n"); |
| } |
| else if (!returntypeissimple) |
| c_writer.write(outparamTypeName + "\tpReturn = NULL;\n"); |
| else if (returntype.isNillable() || returntype.isOptional() |
| || CUtils.isPointerType(outparamTypeName)) |
| { |
| c_writer.write(outparamTypeName); |
| if (!CUtils.isPointerType(outparamTypeName)) |
| c_writer.write(" *"); |
| |
| c_writer.write("\tRet = NULL;\n"); |
| } |
| else |
| { |
| String initValue = CUtils.getInitValueForType(outparamTypeName); |
| if (initValue != null) |
| c_writer.write(outparamTypeName + " Ret = " + initValue + ";\n"); |
| else if (outparamTypeName.equals("xsdc__dateTime") |
| || outparamTypeName.equals("xsdc__date") |
| || outparamTypeName.equals("xsdc__time")) |
| { |
| c_writer.write(outparamTypeName + " Ret;\n"); |
| c_writer.write("\tmemset(&Ret,0,sizeof(" + outparamTypeName + "));\n"); |
| } |
| else |
| c_writer.write(outparamTypeName + " Ret;\n"); |
| } |
| } |
| |
| //writer.write("\tchar* cFaultcode;\n"); |
| //writer.write("\tchar* cFaultstring;\n"); |
| //writer.write("\tchar* cFaultactor;\n"); |
| c_writer.write("\tconst char *\tpcCmplxFaultName = NULL;\n\n"); |
| |
| c_writer.write("\n\tif( AXISC_SUCCESS != axiscCallInitialize(call, CPP_RPC_PROVIDER" |
| + "))\n\t\treturn "); |
| |
| if (returntype != null) |
| { |
| if (returntypeisarray) |
| c_writer.write("RetArray;\n"); |
| else if (CUtils.isPointerType(outparamTypeName) || |
| (returntypeissimple && !(returntype.isNillable() || returntype.isOptional()))) |
| c_writer.write("Ret;\n"); |
| else if (returntypeissimple) |
| c_writer.write("*Ret;\n"); |
| else |
| c_writer.write("pReturn;\n"); |
| } |
| else |
| c_writer.write(";\n"); |
| |
| c_writer.write("\n"); |
| |
| c_writer.write("\tif( NULL == axiscCallGetTransportProperty(call, \"SOAPAction\", 0))\n"); |
| c_writer.write("\t\taxiscCallSetTransportProperty(call, AXISC_SOAPACTION_HEADER,\"" |
| + minfo.getSoapAction() + "\");\n"); |
| |
| c_writer.write("\taxiscCallSetSOAPVersion(call, SOAP_VER_1_1);\n"); |
| //TODO check which version is it really. |
| c_writer.write("\taxiscCallSetOperation(call, \"" + minfo.getMethodname() |
| + "\", \"" + wscontext.getWrapperInfo().getTargetNameSpaceOfWSDL() |
| + "\");\n"); |
| c_writer.write ("\taxiscStubApplyUserPreferences(stub);\n"); |
| |
| for (int i = 0; i < paramsB.size(); i++) |
| { |
| type = wscontext.getTypemap().getType( ((ParameterInfo) paramsB.get(i)).getSchemaName()); |
| |
| if (type != null) |
| { |
| paramTypeName = type.getLanguageSpecificName(); |
| typeisarray = type.isArray(); |
| } |
| else |
| { |
| paramTypeName = ((ParameterInfo) paramsB.get(i)).getLangName(); |
| typeisarray = false; |
| } |
| |
| typeissimple = CUtils.isSimpleType(paramTypeName); |
| |
| if (typeisarray) |
| { |
| //arrays |
| QName qname = CUtils.getArrayType(type).getName(); |
| String containedType = null; |
| if (CUtils.isSimpleType(qname)) |
| { |
| containedType = CUtils.getSimpleType(qname); |
| c_writer.write("\taxiscCallAddBasicArrayParameter(call, "); |
| c_writer.write("(Axisc_Array *)Value" + i + ", " |
| + CUtils.getXSDEnumeratorForType(containedType) |
| + ", \"" |
| + ((ParameterInfo) paramsB.get(i)).getParamNameAsSOAPString() |
| + "\""); |
| } |
| else |
| { |
| containedType = qname.getLocalPart(); |
| c_writer.write("\taxiscCallAddCmplxArrayParameter(call, "); |
| c_writer.write("(Axisc_Array *)Value" + i |
| + ",(void *) Axis_Serialize_" + containedType |
| + ",(void *) Axis_Delete_" + containedType |
| + ",\"" + ((ParameterInfo) paramsB.get(i)).getParamNameAsSOAPString() + "\"" |
| + ",Axis_URI_" + containedType); |
| } |
| } |
| else if (typeissimple) |
| { |
| |
| //for simple types |
| if (((ParameterInfo) paramsB.get(i)).isNillable() |
| || CUtils.isPointerType(paramTypeName)) |
| { |
| c_writer.write("\taxiscCallAddParameter(call, "); |
| c_writer.write("(void *) Value" |
| + i |
| + ", \"" |
| + ((ParameterInfo) paramsB.get(i)) |
| .getParamNameAsSOAPString() + "\", " |
| + CUtils.getXSDEnumeratorForType(paramTypeName)); |
| } |
| else |
| { |
| c_writer.write("\taxiscCallAddParameter(call, "); |
| c_writer.write("(void *) &Value" |
| + i |
| + ", \"" |
| + ((ParameterInfo) paramsB.get(i)) |
| .getParamNameAsSOAPString() + "\", " |
| + CUtils.getXSDEnumeratorForType(paramTypeName)); |
| } |
| } |
| else |
| { |
| //for complex types |
| c_writer.write("\taxiscCallAddCmplxParameter(call, "); |
| c_writer.write("Value" + i + ",(void *) Axis_Serialize_" |
| + paramTypeName + ",(void *) Axis_Delete_" |
| + paramTypeName + ",\"" |
| + ((ParameterInfo) paramsB.get(i)).getParamNameAsSOAPString() |
| + "\",Axis_URI_" + paramTypeName); |
| } |
| c_writer.write(");\n"); |
| } |
| c_writer.write("\n\tif( AXISC_SUCCESS == axiscCallSendAndReceive(call))\n\t{\n"); |
| c_writer.write("\t\tif( AXISC_SUCCESS == axiscCallCheckMessage(call, \"" |
| + minfo.getOutputMessage().getLocalPart() + "\",\"" |
| + wscontext.getWrapperInfo().getTargetNameSpaceOfWSDL() |
| + "\"))\n\t\t{\n"); |
| |
| String paramTagName = ""; |
| |
| if( returntype != null) |
| paramTagName = returntype.getParamNameAsSOAPString(); |
| |
| if (isAllTreatedAsOutParams) |
| { |
| String currentParamName; |
| String currentParaType; |
| for (int i = 0; i < paramsC.size(); i++) |
| { |
| ParameterInfo currentType = (ParameterInfo) paramsC.get(i); |
| type = wscontext.getTypemap().getType( |
| currentType.getSchemaName()); |
| if (type != null) |
| { |
| currentParaType = type.getLanguageSpecificName(); |
| typeisarray = type.isArray(); |
| } |
| else |
| { |
| currentParaType = ((ParameterInfo) paramsC.get(i)) |
| .getLangName(); |
| typeisarray = false; |
| } |
| typeissimple = CUtils.isSimpleType(currentParaType); |
| |
| currentParamName = "*OutValue" + i; |
| |
| // Some code need to be merged as we have some duplicated in |
| // coding here. |
| if (typeisarray) |
| { |
| QName qname = CUtils.getArrayType(type).getName(); |
| String containedType = null; |
| if (CUtils.isSimpleType(qname)) |
| { |
| containedType = CUtils.getSimpleType(qname); |
| c_writer.write("\n\t\tAxisc_Array * pReturn" + i |
| + " = axiscCallGetBasicArray(call, " |
| + CUtils.getXSDEnumeratorForType (containedType) |
| + ",\"" + currentType.getParamNameAsSOAPString() + "\",0);\n\n"); |
| c_writer.write("\t\tif( OutValue" + i + " != NULL)\n"); |
| c_writer.write("\t\t{\n"); |
| c_writer.write("\t\t\tif( *OutValue" + i + " != NULL)\n"); |
| c_writer.write("\t\t\t\taxiscAxisDelete(*OutValue" + i + ", XSDC_ARRAY);\n"); |
| c_writer.write("\t\t\t\t*OutValue" + i + " = pReturn;\n"); |
| c_writer.write("\t\t}\n\n"); |
| c_writer.write("\t\telse\n"); |
| c_writer.write("\t\t\taxiscAxisDelete(pReturn" + i + ", XSDC_ARRAY);\n"); |
| } |
| else |
| { |
| containedType = qname.getLocalPart(); |
| c_writer.write("\n\t\tif( OutValue" + i + " != NULL)\n" ); |
| c_writer.write("\t\t{\n"); |
| c_writer.write("\t\t\tif( " + currentParamName + " != NULL)\n"); |
| c_writer.write("\t\t\t\tAxis_Delete_" + containedType + "_Array(" + currentParamName + ", 0);\n"); |
| c_writer.write("\t\t\t" + currentParamName + " = (" + containedType + " *)Axis_Create_" + containedType + "_Array(0);\n"); |
| |
| c_writer.write("\t\t\taxiscCallGetCmplxArray(call, " + currentParamName |
| + ",(void *) Axis_DeSerialize_" + containedType |
| + ",(void *) Axis_Create_" + containedType |
| + ",(void *) Axis_Delete_" + containedType |
| + ",\"" +currentType.getElementNameAsSOAPString() |
| + "\",Axis_URI_" + containedType + ");\n"); |
| c_writer.write("\t\t}\n"); |
| c_writer.write("\t\telse\n"); |
| c_writer.write("\t\t{\n"); |
| c_writer.write("\t\t\t// Unable to return value, but will deserialize to ensure subsequent elements can be correctly processed.\n"); |
| c_writer.write("\t\t\t" + containedType + "_Array * pTemp" + i + " = (" + containedType + " *)Axis_Create_" + containedType + "_Array(0);\n"); |
| c_writer.write("\t\t\taxiscCallGetCmplxArray(call, pTemp" + i |
| + ",(void *) Axis_DeSerialize_" + containedType |
| + ",(void *) Axis_Create_" + containedType |
| + ",(void *) Axis_Delete_" + containedType |
| + ",\"" + currentType.getElementNameAsSOAPString() |
| + "\",Axis_URI_" + containedType + ");\n"); |
| c_writer.write("\t\t\t\tAxis_Delete_" + containedType + "_Array(pTemp" + i + ", 0);\n"); |
| c_writer.write("\t\t}\n"); |
| } |
| } |
| else |
| { |
| if (typeissimple) |
| { |
| if( i > 0) |
| c_writer.write( "\n"); |
| |
| if (CUtils.isPointerType(currentParaType)) |
| { |
| String xsdType = CUtils.getClassNameFromParamInfoConsideringArrays ((ParameterInfo) paramsC.get (i), wscontext); |
| |
| if( !CUtils.isPointerType(xsdType)) |
| xsdType += " *"; |
| |
| c_writer.write( "\n"); |
| c_writer.write( "\t\t\tif( pReturn" + i + " != NULL && OutValue" + i + " != NULL)\n"); |
| c_writer.write( "\t\t\t{\n"); |
| c_writer.write( "\t\t\t\tif( *OutValue" + i + " != NULL)\n"); |
| c_writer.write( "\t\t\t\t{\n"); |
| c_writer.write( "\t\t\t\t\tint\tiStringSize" + i + " = strlen( (char *) *OutValue" + i + ");\n"); |
| c_writer.write( "\t\t\t\t\tint\tiStrLenValue" + i + " = strlen( pReturn" + i + ");\n"); |
| c_writer.write( "\n"); |
| c_writer.write( "\t\t\t\t\tif( iStrLenValue" + i + " > iStringSize" + i + ")\n"); |
| c_writer.write( "\t\t\t\t\t{\n"); |
| c_writer.write( "\t\t\t\t\t\t*OutValue" + i + " =(" + xsdType + ") axiscAxisNew(XSDC_STRING, iStrLenValue" + i + " + 1);\n"); |
| c_writer.write( "\t\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn" + i + ");\n"); |
| c_writer.write( "\t\t\t\t\t}\n"); |
| c_writer.write( "\t\t\t\t\telse\n"); |
| c_writer.write( "\t\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn" + i + ");\n"); |
| c_writer.write( "\t\t\t\t}\n"); |
| c_writer.write( "\t\t\t\telse\n"); |
| c_writer.write( "\t\t\t\t{\n"); |
| c_writer.write( "\t\t\t\t\t*OutValue" + i + " = (" + xsdType + ") axiscAxisNew(XSDC_STRING,strlen( pReturn" + i + ") + 1);\n"); |
| c_writer.write( "\t\t\t\t\tstrcpy( (char *) *OutValue" + i + ", pReturn" + i + ");\n"); |
| c_writer.write( "\t\t\t\t}\n"); |
| c_writer.write( "\t\t\t}\n"); |
| c_writer.write( "\n"); |
| c_writer.write( "\t\t\taxiscAxisDelete( (void *) pReturn" + i + ", " + CUtils.getXSDEnumeratorForType( currentParaType) + ");\n"); |
| } |
| else |
| { |
| c_writer.write( "\t\t" + currentParaType + " * pReturn" + i + " = axiscCall" + CUtils.getDeserializerMethodName( currentParaType, false) + "(call, \"" + currentType.getParamNameAsSOAPString() + "\", 0);\n"); |
| c_writer.write( "\n"); |
| c_writer.write( "\t\tif( pReturn" + i + " != NULL && OutValue" + i + " != NULL)\n"); |
| c_writer.write( "\t\t{\n"); |
| c_writer.write( "\t\t\t// OutValue" + i + " is not nillable.\n"); |
| c_writer.write( "\t\t\t*OutValue" + i + " = *pReturn" + i + ";\n"); |
| c_writer.write( "\t\t}\n"); |
| c_writer.write( "\n"); |
| c_writer.write( "\t\taxiscAxisDelete(pReturn" + i + ", " + CUtils.getXSDEnumeratorForType( currentParaType) + ");\n"); |
| } |
| } |
| else |
| { |
| c_writer.write("\t\t\t" |
| + currentParamName |
| + " = (" |
| + currentParaType |
| + " *) axiscCallGetCmplxObject(call, (void *) Axis_DeSerialize_" + currentParaType |
| + ",(void *) Axis_Create_" + currentParaType |
| + ",(void *) Axis_Delete_" + currentParaType |
| + ",\"" + currentType.getParamNameAsSOAPString() |
| + "\",0);\n"); |
| } |
| } |
| } |
| c_writer.write("\t\t}\n"); |
| c_writer.write("\t}\n\n"); |
| c_writer.write("\taxiscCallUnInitialize(call);\n"); |
| } |
| else if (returntype == null) |
| { |
| c_writer.write("\t\t\t/*not successful*/\n\t\t\t}\n"); |
| c_writer.write("\t}\n\n"); |
| c_writer.write("\taxiscCallUnInitialize(call);\n"); |
| } |
| else if (returntypeisarray) |
| { |
| QName qname = CUtils.getArrayType(retType).getName(); |
| String containedType = null; |
| if (CUtils.isSimpleType(qname)) |
| { |
| containedType = CUtils.getSimpleType(qname); |
| c_writer.write("\t\t\tRetArray = (" + containedType + "_Array *)axiscCallGetBasicArray(call, " |
| + CUtils.getXSDEnumeratorForType(containedType) + ",\"" |
| + paramTagName + "\",0);\n"); |
| } |
| else |
| { |
| containedType = qname.getLocalPart(); |
| c_writer.write("\t\t\tRetArray = (" + containedType |
| + "_Array *) axiscCallGetCmplxArray(call, (Axisc_Array *)RetArray,(void *) Axis_DeSerialize_" |
| + containedType); |
| //damitha |
| c_writer.write(",(void *) Axis_Create_" + containedType |
| + ",(void *) Axis_Delete_" + containedType |
| + ",\"" + paramTagName |
| + "\",Axis_URI_" + containedType + ");\n"); |
| } |
| c_writer.write("\t\t}\n\t}\n\n"); |
| c_writer.write("\taxiscCallUnInitialize(call);\n\n"); |
| |
| c_writer.write("\treturn RetArray;\n"); |
| } |
| else if (returntypeissimple) |
| { |
| c_writer.write("\t\t\t" + outparamTypeName); |
| if (!CUtils.isPointerType(outparamTypeName)) |
| c_writer.write(" *"); |
| |
| c_writer.write(" pReturn = axiscCall" |
| + CUtils.getDeserializerMethodName(outparamTypeName, |
| false) + "(call, \"" + paramTagName + "\", 0);\n\n"); |
| c_writer.write("\t\t\tif( pReturn)\n"); |
| c_writer.write("\t\t\t{\n"); |
| if (CUtils.isPointerType(outparamTypeName)) |
| { |
| c_writer.write("\t\t\t\tRet = pReturn;\n"); |
| } |
| else if (returntype.isOptional() || returntype.isNillable()) |
| c_writer.write("\t\t\t\tRet = pReturn;\n"); |
| else |
| { |
| c_writer.write("\t\t\t\tRet = *pReturn;\n"); |
| c_writer.write("\t\t\t\taxiscAxisDelete(pReturn, " + CUtils.getXSDEnumeratorForType(outparamTypeName) + ");\n"); |
| } |
| |
| c_writer.write("\t\t\t}\n"); |
| c_writer.write("\t\t}\n"); |
| c_writer.write("\t}\n\n"); |
| c_writer.write("\taxiscCallUnInitialize(call);\n"); |
| c_writer.write("\treturn Ret;\n"); |
| } |
| else |
| { |
| outparamTypeName = returntype.getLangName(); |
| //need to have complex type name without * |
| c_writer.write("\t\t\tpReturn = (" + outparamTypeName |
| + " *) axiscCallGetCmplxObject(call, (void *) Axis_DeSerialize_" |
| + outparamTypeName + ",(void *) Axis_Create_" |
| + outparamTypeName + ",(void *) Axis_Delete_" |
| + outparamTypeName + ",\"" + paramTagName |
| + "\",0);\n\t\t\t}\n"); |
| c_writer.write("\t}\n\n"); |
| c_writer.write("\taxiscCallUnInitialize(call);\n\n"); |
| c_writer.write("\treturn pReturn;\n"); |
| |
| } |
| |
| c_writer.write("}\n"); |
| } |
| |
| |
| /* |
| * Used by literal code too! |
| */ |
| protected void writeFaultHandlingCode(MethodInfo minfo) throws WrapperFault, IOException |
| { |
| c_writer.write ("\taxiscCallSetSoapFaultNamespace(call, \"" |
| + wscontext.getServiceInfo().getTargetEndpointURI () + "\");\n"); |
| |
| //to get fault info |
| Iterator paramsFault = minfo.getFaultType ().iterator (); |
| String faultInfoName = null; |
| String langName = null; |
| |
| while (paramsFault.hasNext ()) |
| { |
| FaultInfo info = (FaultInfo) paramsFault.next (); |
| faultInfoName = info.getFaultInfo (); |
| |
| // Looking through the list of attributes for the 'error' part of |
| // the fault message. If found, update the faultInfoName with the |
| // 'localname' of the qname of the attribute. |
| Iterator infoArrayListIterator = info.getParams ().iterator (); |
| boolean found = false; |
| |
| while (infoArrayListIterator.hasNext () && !found) |
| { |
| ParameterInfo paramInfo = (ParameterInfo) infoArrayListIterator.next (); |
| |
| if (paramInfo != null) |
| if ("error".equals (paramInfo.getParamName ())) |
| { |
| faultInfoName = paramInfo.getElementName ().getLocalPart (); |
| found = true; |
| } |
| } |
| |
| ArrayList paramInfo = info.getParams (); |
| for (int i = 0; i < paramInfo.size (); i++) |
| { |
| ParameterInfo par = (ParameterInfo) paramInfo.get (i); |
| langName = par.getLangName (); |
| String faultType = CUtils.getClassNameFromParamInfoConsideringArrays (par,wscontext); |
| String faultTypeName = faultType; |
| if (faultType.lastIndexOf('*') != -1) |
| faultTypeName = faultType.substring(0, faultType.lastIndexOf('*')); |
| |
| // TODO Currently we do not create exception classes for simple types! |
| if (CUtils.isSimpleType (faultTypeName)) |
| continue; |
| |
| c_writer.write ("\taxiscCallAddSoapFaultToList(call, \"" |
| + faultInfoName + "\", " |
| + "(void*) Axis_Create_" + langName + ", " |
| + "(void*) Axis_Delete_" + langName + ", " |
| + "(void*) Axis_DeSerialize_" + langName + ");\n"); |
| } |
| } |
| } |
| |
| /* (non-Javadoc) |
| * @see org.apache.axis.wsdl.wsdl2ws.cpp.CPPClassWriter#writeGlobalCodes() |
| * Used by literal code too! |
| */ |
| protected void writeGlobalCodes() throws WrapperFault |
| { |
| } |
| } |