axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r395782 - in /webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal: ClientStubHeaderWriter.java ClientStubWriter.java
Date Fri, 21 Apr 2006 05:05:21 GMT
Author: nadiramra
Date: Thu Apr 20 22:05:19 2006
New Revision: 395782

URL: http://svn.apache.org/viewcvs?rev=395782&view=rev
Log:
C support fixes/enhancements.

Modified:
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java
    webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java?rev=395782&r1=395781&r2=395782&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java
Thu Apr 20 22:05:19 2006
@@ -26,6 +26,9 @@
 
 import org.apache.axis.wsdl.wsdl2ws.CUtils;
 import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
+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;
 
@@ -40,6 +43,136 @@
         throws WrapperFault
     {
         super(wscontext);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+     */
+    protected void writeMethods() throws WrapperFault
+    {
+        MethodInfo minfo;
+        try
+        {
+            writer.write("\n");
+            writer.write("/* --- Functions relating to web service client proxy --- */\n");
+            writer.write("extern AXISCHANDLE get_" + classname + "_stub(const char* pchEndPointUri);\n");
+            writer.write("extern void destroy_" + classname + "_stub(AXISCHANDLE pStub);\n");
+            writer.write("extern int get_" + classname + "_Status(AXISCHANDLE pStub);\n");
+
+            writer.write("\n");
+            writer.write("/* --- Functions relating to web service methods --- */\n");
+
+            for (int i = 0; i < methods.size(); i++)
+            {
+                minfo = (MethodInfo) this.methods.get(i);
+                boolean isAllTreatedAsOutParams = false;
+                int noOfOutParams = minfo.getOutputParameterTypes().size();
+                
+                //write return type
+                if (0 == noOfOutParams)
+                    writer.write("extern void ");
+                else if (1 == noOfOutParams)
+                {
+                    ParameterInfo returnParam =
+                        (ParameterInfo) minfo.getOutputParameterTypes().iterator().next();
+                    String outParamTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(returnParam,
wscontext);
+                    if ((outParamTypeName.lastIndexOf ("_Array") > 0) 
+                            || (CUtils.isSimpleType(outParamTypeName)
+                            && (returnParam.isNillable() || returnParam.isOptional())
+                            && !(CUtils.isPointerType(outParamTypeName))))
+                        writer.write("extern " + outParamTypeName + " * ");
+                    else
+                        writer.write("extern " + outParamTypeName + " ");
+                }
+                else
+                {
+                    isAllTreatedAsOutParams = true;
+                    writer.write("extern void ");
+                }
+                
+                //write return type
+                writer.write(minfo.getMethodname() + "(AXISCHANDLE pStub");             
  
+
+                //write parameter names 
+                boolean hasInputParms = false;
+                Iterator params = minfo.getInputParameterTypes().iterator();
+                for (int j = 0; params.hasNext(); j++)
+                {
+
+                    writer.write(", ");
+                    hasInputParms = true;
+                    ParameterInfo nparam = (ParameterInfo) params.next();
+                    String paramTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(nparam,
wscontext);
+                    Type type = nparam.getType();
+                    String baseTypeName = null;
+                    
+                    if (type.isSimpleType())
+                        baseTypeName = CUtils.getclass4qname (type.getBaseType ());
+                    else
+                        baseTypeName = paramTypeName;
+                    
+                    if (nparam.getType().isAttachment())
+                        writer.write("AXISCHANDLE *Value" + j);
+                    else if ((paramTypeName.lastIndexOf ("_Array") > 0)
+                                || (CUtils.isSimpleType(baseTypeName)
+                                        && (nparam.isNillable() || nparam.isOptional())
+                                        && !(CUtils.isPointerType(baseTypeName))))
+                        writer.write(paramTypeName + " * Value" + j);
+                    else
+                        writer.write(paramTypeName + " Value" + j);
+                }
+
+                if (isAllTreatedAsOutParams)
+                {
+                    params = minfo.getOutputParameterTypes().iterator();
+                    for (int j = 0; params.hasNext(); j++)
+                    {
+                        ParameterInfo nparam = (ParameterInfo) params.next();
+                        String paramType = WrapperUtils.getClassNameFromParamInfoConsideringArrays(
nparam, wscontext);
+                        Type type = nparam.getType();
+                        String baseTypeName = null;
+                        
+                        if (type.isSimpleType())
+                            baseTypeName = CUtils.getclass4qname (type.getBaseType ());
+                        else
+                            baseTypeName = paramType;
+                        
+                        boolean bTypeHasStar = paramType.endsWith( "*");
+                        
+
+                        writer.write(", ");
+                        
+                        writer.write("AXIS_OUT_PARAM " + paramType);
+                        if (CUtils.isSimpleType(baseTypeName))
+                        {
+                            if ((nparam.isOptional() 
+                                    || nparam.isNillable()) 
+                                    && !CUtils.isPointerType(baseTypeName))
+                            {
+                                if (bTypeHasStar)
+                                    writer.write(" *");
+                                else
+                                    writer.write(" **");
+                            }
+                            else if (CUtils.isPointerType(baseTypeName) || !bTypeHasStar)
+                                writer.write(" *");
+                        }
+                        else if(bTypeHasStar)
+                            writer.write(" *");
+                        else
+                            writer.write(" **");
+                        
+                        writer.write(" OutValue" + j);
+                    } // for loop
+                }
+                writer.write(");\n");
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            throw new WrapperFault(e);
+        }
     }
 
     /*

Modified: webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java?rev=395782&r1=395781&r2=395782&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
(original)
+++ webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
Thu Apr 20 22:05:19 2006
@@ -65,11 +65,11 @@
           // get_xxx_stub() routine
           writer.write("AXISCHANDLE get_" + classname + "_stub(const char* pchEndPointUri)\n{\n");
           writer.write("\tif(pchEndPointUri)\n");
-          writer.write("\t\treturn axiscStubCreate(pchEndPointUri, AXISC_PTHTTP1_1);\n");
+          writer.write("\t\treturn axiscStubCreate(pchEndPointUri, AXISC_APTHTTP1_1);\n");
           writer.write("\telse\n");
           writer.write("\t\treturn axiscStubCreate(\"" 
                   + wscontext.getWrapInfo().getTargetEndpointURI() 
-                  + "\", AXISC_PTHTTP1_1);\n");
+                  + "\", AXISC_APTHTTP1_1);\n");
           writer.write("}\n\n");
           
           // destroy_xxxx_stub()
@@ -173,11 +173,13 @@
         else // for AnyType too
             writer.write(outparamType + "*");
    
-        writer.write(" " + methodName + "(AXISCHANDLE stub, ");
+        writer.write(" " + methodName + "(AXISCHANDLE stub");
         ArrayList paramsB = (ArrayList) params;
         ParameterInfo paramtype = null;
         if (0 < paramsB.size ())
         {
+            writer.write(", ");
+            
             type = wscontext.getTypemap ().getType (((ParameterInfo) paramsB.get (0)).getSchemaName
());
             paramtype = (ParameterInfo) paramsB.get (0);
             String baseTypeName = null;
@@ -646,6 +648,7 @@
                     }
                     else
                     {
+                        // TODO
                         containedType = qname.getLocalPart ();
                         writer.write("\n\t\t\tif (OutValue" + i + " != NULL)\n" );
                         writer.write("\t\t\t{\n");
@@ -822,79 +825,35 @@
         }
         else if (returntypeissimple)
         {
-            if (returntype.isNillable ())
+            if (returntype.isNillable () 
+                    || CUtils.isPointerType(outparamType))
             {
-                if( CUtils.isPointerType( outparamType))
-                {
-                    writer.write( "\t\t\t" + outparamType + " pReturn = " 
-                            + "axiscCall"
-                            + CUtils.getParameterGetValueMethodName( outparamType, false)

-                            + "(call, \"" + returntype.getParamName() + "\", 0);\n");
-                }
-                else
-                {
-                    writer.write( "\t\t\t" + outparamType + " * pReturn = " 
-                            + "axiscCall"
-                            + CUtils.getParameterGetValueMethodName( outparamType, false)

-                            + "(call, \"" + returntype.getParamName() + "\", 0);\n");
-                }
-                
-                writer.write( "\n");
-                writer.write( "\t\t\tif( pReturn != NULL)\n");
-                writer.write( "\t\t\t{\n");
-                if( CUtils.isPointerType(outparamType))
-                {
-                    writer.write( "\t\t\t\tRet = axiscAxisNew(XSDC_STRING, strlen( pReturn)
+ 1);\n");
-                    writer.write( "\t\t\t\tstrcpy( Ret, pReturn);\n");
-                }
-                else
-                {
-                    writer.write( "\t\t\t\tRet = malloc(sizeof( " + outparamType + ");\n");
-                    writer.write( "\t\t\t\t*Ret = *pReturn;\n");
-                }
-                
-                writer.write( "\t\t\t\taxiscAxisDelete( (void *) pReturn, " + CUtils.getXSDTypeForBasicType(
outparamType) + ");\n");
-                writer.write( "\t\t\t}\n");
+                // Just return the pointer as-is - no need to delete.
+                writer.write( "\t\t\tRet = axiscCall"
+                        + CUtils.getParameterGetValueMethodName( outparamType, false) 
+                        + "(call, \"" + returntype.getParamName() + "\", 0);\n");
+
                 writer.write( "\t\t}\n");
             }
             else
             {
-                if (CUtils.isPointerType(outparamType))
-                {
-                    writer.write ("\t\t\t" + outparamType + " pReturn = " 
-                            + "axiscCall"
-                            + CUtils.getParameterGetValueMethodName(outparamType,false) 
-                            + "(call, \"" + returntype.getParamName () + "\", 0);\n");
-                    writer.write ("\t\t\tif(pReturn)\n");
-                    writer.write ("\t\t\t{\n");
-                    writer.write ("\t\t\t\tRet = axiscAxisNew(XSDC_STRING, strlen( pReturn)
+ 1);\n");
-                    writer.write ("\t\t\t\tstrcpy( Ret, pReturn);\n");
-                    writer.write ("\t\t\t\taxiscAxisDelete( pReturn, XSD_STRING);\n");
-                    writer.write ("\t\t\t}\n");
-                }
-                else
-                {
-                    writer.write ("\t\t\t" + outparamType + " * pReturn = " 
-                            + "axiscCall"
-                            + CUtils.getParameterGetValueMethodName(outparamType, false)

-                            + "(call, \"" + returntype.getSOAPElementNameAsString() + "\",
0);\n");
-                    writer.write ("\t\t\tif(pReturn)\n");
-                    writer.write ("\t\t\t{\n");
-                    
-                    if( CUtils.isPointerType( outparamType))
-                        writer.write ("\t\t\t\tRet = *pReturn;\n");
-                    else
-                        writer.write ("\t\t\t\tRet = *pReturn;\n");
-    
-                    writer.write ("\t\t\t\taxiscAxisDelete( (void *) pReturn, " + CUtils.getXSDTypeForBasicType(
outparamType) + ");\n");
-                    writer.write ("\t\t\t}\n");
-                }
+                writer.write ("\t\t\t" + outparamType + " * pReturn = " 
+                        + "axiscCall"
+                        + CUtils.getParameterGetValueMethodName(outparamType, false) 
+                        + "(call, \"" + returntype.getSOAPElementNameAsString() + "\", 0);\n");
+                
+                writer.write ("\t\t\tif(pReturn)\n");
+                writer.write ("\t\t\t{\n");
+                
+                writer.write ("\t\t\t\tRet = *pReturn;\n");
+                // TODO - hex and base and any...what about internal pointers?  
+                // TODO - need to null out the pointers in the structure.
+                writer.write ("\t\t\t\taxiscAxisDelete( (void *) pReturn, " 
+                        + CUtils.getXSDTypeForBasicType( outparamType) + ");\n");
+
+                writer.write ("\t\t\t}\n");
                 
-                // TODO If we unexpectedly receive a nill value, when nillable="false" we
should do something appropriate, perhaps as below:
-//                              writer.write("\t\t\telse");
-//                              writer.write("\t\t\t\tthrow new Exception(\"Unexpected use
of nill\");");
                 writer.write ("\t\t}\n");
-
             }
             writer.write ("\t}\n");
             writer.write ("\taxiscCallUnInitialize(call);\n");



Mime
View raw message