You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2006/05/15 02:18:27 UTC
svn commit: r406472 - in /webservices/axis/trunk/c:
src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/
tests/auto_build/testcases/client/c/ tests/auto_build/testcases/client/cpp/
tests/auto_build/testcases/tests/
Author: nadiramra
Date: Sun May 14 17:18:24 2006
New Revision: 406472
URL: http://svn.apache.org/viewcvs?rev=406472&view=rev
Log:
C support fixes/enhancements. Testcases for C bindings.
Added:
webservices/axis/trunk/c/tests/auto_build/testcases/client/c/InOutClient.c
webservices/axis/trunk/c/tests/auto_build/testcases/tests/InOutC.xml
Modified:
webservices/axis/trunk/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/InOutClient.cpp
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=406472&r1=406471&r2=406472&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 Sun May 14 17:18:24 2006
@@ -640,15 +640,13 @@
}
else
{
- // TODO
containedType = qname.getLocalPart ();
writer.write("\n\t\t\tif (OutValue" + i + " != NULL)\n" );
- writer.write("\t\t\t{\n");
+ writer.write("\t\t{\n");
- writer.write("\t\t\t\tif (" + currentParamName + " == NULL)\n");
- writer.write("\t\t\t\t\t" + currentParamName + " = new " + containedType + "_Array();\n");
- writer.write("\t\t\t\telse\n");
- writer.write("\t\t\t\t\t(" + currentParamName + ")->clear();\n");
+ writer.write("\t\t\t\tif (" + currentParamName + " != NULL)\n");
+ writer.write("\t\t\t\t\t" + currentParamName + " = Axis_Delete_" + containedType + "_Array(" + currentParamName + ",0);\n");
+ writer.write("\t\t\t\t" + currentParamName + " = Axis_Create_" + containedType + "_Array(0);\n");
writer.write("\t\t\t\taxiscCallGetCmplxArray(call, " + currentParamName
+ ", (void*) Axis_DeSerialize_" + containedType
@@ -663,14 +661,14 @@
writer.write("\t\t\t\t/* Unable to return value, but will deserialize to ensure subsequent elements can be correctly processed. */\n");
writer.write("\t\t\t\t" + containedType + "_Array * pTemp" + i
- + " = new " + containedType + "_Array();\n");
+ + " = Axis_Create_" + containedType + "_Array(0);\n");
writer.write("\t\t\t\taxiscCallGetCmplxArray(call, pTemp" + i
+ ", (void*) Axis_DeSerialize_" + containedType
+ ", (void*) Axis_Create_" + containedType
+ ", (void*) Axis_Delete_" + containedType
+ ", \"" + currentType.getElementNameAsString ()
+ "\", Axis_URI_" + containedType + ");\n");
- writer.write("\t\t\t\tdelete pTemp" + i + ";\n");
+ writer.write("\t\t\t\tAxis_Delete_" + containedType + "_Array(pTemp" + i + ", 0);\n");
writer.write("\t\t\t}\n");
}
}
@@ -679,6 +677,7 @@
if( i > 0)
writer.write( "\n");
+ writer.write("\t\t\t{\n"); // begin scope
if (CUtils.isPointerType(baseTypeName))
{
String xsdType = WrapperUtils.getClassNameFromParamInfoConsideringArrays ((ParameterInfo) paramsC.get (i), wscontext);
@@ -697,7 +696,7 @@
+ "(call, \"" + currentType.getParamName() + "\", 0);\n");
writer.write( "\n");
writer.write( "\t\t\tif( pReturn" + i + " != NULL && OutValue" + i + " != NULL)\n");
- writer.write( "\t\t\t\t{\n");
+ writer.write( "\t\t\t{\n");
writer.write( "\t\t\t\tif( *OutValue" + i + " != NULL)\n");
writer.write( "\t\t\t\t{\n");
writer.write( "\t\t\t\t\tint\tiStringSize" + i + " = strlen( (char *) *OutValue" + i + ");\n");
@@ -746,6 +745,7 @@
writer.write( "\n");
writer.write( "\t\t\taxiscAxisDelete( (void *) pReturn" + i + ", " + CUtils.getXSDTypeForBasicType( baseTypeName) + ");\n");
}
+ writer.write("\t\t\t}\n"); // end scope
}
else if (currentType.isAnyType ())
{
Added: webservices/axis/trunk/c/tests/auto_build/testcases/client/c/InOutClient.c
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/c/InOutClient.c?rev=406472&view=auto
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/c/InOutClient.c (added)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/c/InOutClient.c Sun May 14 17:18:24 2006
@@ -0,0 +1,246 @@
+// 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.
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE */
+/* ---------------------------------------------------------------- */
+/* CHANGES TO THIS FILE MAY ALSO REQUIRE CHANGES TO THE */
+/* C-EQUIVALENT FILE. PLEASE ENSURE THAT IT IS DONE. */
+/* ---------------------------------------------------------------- */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+
+/*
+ Perform a variety of tests.
+ 1) pass no parameters and get no return
+ 2) pass no parameters and get an int return
+ 3) pass a mixture of primitive parameters and get no return
+ 4) pass a mixture of primitives, arrays and complex types all of which are not nillable
+ 5) pass a mixture of primitives, arrays and complex types some of which are nillable
+ 6) pass multiple arrays of different primitive types and get an int return
+ 7) pass a complex type which has primitives, arrays and complex type and return the
+ same type
+ 8) pass a complex type which has primitives, arrays and complex type and return the
+ same type with element set as nil
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "CommonClientTestCode.h"
+#include "InOut.h"
+
+#define ARRAYSIZE 2
+
+int main(int argc, char* argv[])
+{
+ AXISCHANDLE ws;
+
+ char endpoint[256];
+ const char* url="http://localhost:80/axis/InOut";
+
+ static char* str1 = "Apache";
+ static char* str2 = "Axis C++";
+
+ int x = 0;
+ int npr;
+
+ ComplexType1 ct;
+
+ xsdc__string_Array stringArray;
+ xsdc__string arrayOfString[3] = {"One", "Two", "Three"};
+
+ xsdc__int_Array intArray;
+ xsdc__int arrayOfIntVal[3] = {37, 0, 43 };
+ xsdc__int * arrayOfInt[3];
+
+
+ axiscAxisRegisterExceptionHandler(exceptionHandler);
+
+ if(argc>1)
+ url = argv[1];
+
+ sprintf(endpoint, "%s", url);
+ ws = get_InOut_stub(endpoint);
+
+ printf( "noParametersNoReturn\n" );
+ noParametersNoReturn(ws);
+ printf( "noParametersNoReturn returned\n" );
+
+ printf( "noParametersIntReturn\n" );
+ npr = noParametersIntReturn(ws);
+ printf( "noParametersIntReturn returned %d\n" , npr );
+
+ printf( "multiParametersNoReturn\n" );
+ multiParametersNoReturn(ws, "Hey dude", 69, (xsdc__double)17.19);
+ printf( "multiParametersNoReturn returned\n" );
+
+
+ // test multiParametersMultiReturn
+ {
+ xsdc__string outValue0 = "";
+ xsdc__int outValue1 = 0;
+ xsdc__double outValue2 = 0;
+
+ printf( "multiParametersMultiReturn\n" );
+ multiParametersMultiReturn(ws, "Hey dude", 69, (xsdc__double)17.19,
+ &outValue0, &outValue1, &outValue2);
+ printf( "multiParametersMultiReturn returned %s , %d , %g\n" , outValue0 , outValue1, outValue2);
+ }
+
+ //...........................................................
+
+ {
+ for (x=0; x<3; x++)
+ arrayOfInt[x] = &arrayOfIntVal[x];
+
+ intArray.m_Array = arrayOfInt;
+ intArray.m_Size = 3;
+ intArray.m_Type = XSDC_INT;
+
+ stringArray.m_Array = arrayOfString;
+ stringArray.m_Size = 3;
+ stringArray.m_Type = XSDC_STRING;
+
+ ct.ctLong = (xsdc__long)87654321;
+ ct.ctString = "World";
+ ct.ctIntArray = &intArray;
+
+ printf( "multiComplexParametersIntReturn\n" );
+ npr = multiComplexParametersIntReturn(ws, "Hello", &ct, 27, 13.31, &stringArray);
+ printf( "multiComplexParametersIntReturn returned %d\n" , npr );
+ }
+
+ //test multiComplexParametersMultiComplexReturn
+ {
+ xsdc__string OutValue0 = "";
+ ComplexType1* OutValue1;
+ xsdc__int outValue22 = 0;
+ xsdc__double outValue33 = 0;
+
+ printf( "multiComplexParametersMultiComplexReturn\n" );
+ multiComplexParametersMultiComplexReturn(ws, "Hello", &ct, 27, 13.31, &stringArray,
+ &OutValue0, &OutValue1, &outValue22, &outValue33);
+ printf( "multiComplexParametersMultiComplexReturn returned %s , %s\n" , OutValue0 , OutValue1->ctString);
+ }
+
+ //..............................................................................
+ {
+ ComplexNilType1 cnt;
+ xsdc__long longValue = 87654321;
+
+ arrayOfString[0]="Four";
+ arrayOfString[1]=NULL;
+ arrayOfString[2]="Six";
+
+ cnt.ctLong = &longValue;
+ cnt.ctString = NULL;
+ cnt.ctIntArray = &intArray;
+
+ printf( "multiComplexParametersNilIntReturn\n" );
+ npr = multiComplexParametersNilIntReturn(ws, NULL, &cnt, NULL, NULL, &stringArray);
+ printf( "multiComplexParametersNilIntReturn returned %d\n" , npr );
+ }
+
+ /* Commented out as there is a bug in WSDL2Ws.
+ * AXISCPP-565 is the Jira against this problem.
+ xsdc__double* moDouble;
+ xsdc__int* moInt;
+ xsdc__string moString;
+ printf( "noParametersMultiReturn\n" );
+ ws.noParametersMultiReturn(&moDouble, &moInt, &moString);
+ printf( "noParametersMultiReturn returned " , *moDouble , " " , *moInt , " " , moString );
+ *
+ * Removed from WSDL for time being.
+ */
+
+ {
+ xsdc__int_Array int_in;
+ xsdc__double_Array double_in;
+ xsdc__string_Array string_in;
+
+ xsdc__double arrayOfDoubleValue[ARRAYSIZE];
+ xsdc__int arrayOfIntValue[ARRAYSIZE];
+
+ xsdc__double * arrayOfDouble[ARRAYSIZE];
+ xsdc__int * arrayOfInt2[ARRAYSIZE];
+ xsdc__string arrayOfString2[ARRAYSIZE];
+
+ for (x=0; x<ARRAYSIZE; x++)
+ {
+ arrayOfIntValue[x] = x+1;
+ arrayOfInt2[x] = &arrayOfIntValue[x];
+ }
+
+ int_in.m_Array = arrayOfInt2;
+ int_in.m_Size = ARRAYSIZE;
+ int_in.m_Type = XSDC_INT;
+
+ for (x=0; x<ARRAYSIZE; x++)
+ {
+ arrayOfDoubleValue[x] = (xsdc__double)x+71.15656;
+ arrayOfDouble[x] = &arrayOfDoubleValue[x];
+ }
+
+ double_in.m_Array = arrayOfDouble;
+ double_in.m_Size = ARRAYSIZE;
+ double_in.m_Type = XSDC_DOUBLE;
+
+ arrayOfString2[0] = str1;
+ arrayOfString2[1] = str2;
+
+ string_in.m_Array = arrayOfString2;
+ string_in.m_Size = ARRAYSIZE;
+ string_in.m_Type = XSDC_STRING;
+
+ printf( "multiArrayParametersIntReturn\n" );
+ npr = multiArrayParametersIntReturn(ws, &int_in, &double_in, &string_in);
+ printf( "multiArrayParametersIntReturn returned %d\n" , npr );
+ }
+
+ {
+ ComplexType2 ct2;
+ ComplexType2* ctr;
+
+ ct2.ctLong = (xsdc__long)98765432;
+ ct2.ctIntArray = &intArray;
+ ct2.ctString = "Complex2";
+ ct2.ctComplex = &ct;
+
+ printf( "complexParameterComplexReturn\n" );
+ ctr = complexParameterComplexReturn(ws, &ct2);
+ printf( "complexParameterComplexReturn returned %s\n" , ctr->ctString );
+ Axis_Delete_ComplexType2(ctr, 0);
+
+ ct2.ctLong = (xsdc__long)22222222;
+ ct2.ctString = NULL;
+ ct2.ctComplex = NULL;
+
+ printf( "complexParameterComplexReturn with nil parameters\n" );
+ ctr = complexParameterComplexReturn(ws, &ct2);
+ printf( "complexParameterComplexReturn with nil parameters returned %lld\n" , ctr->ctLong );
+ Axis_Delete_ComplexType2(ctr, 0);
+ }
+
+ destroy_InOut_stub(ws);
+
+
+ printf("---------------------- TEST COMPLETE -----------------------------\n");
+
+ return 0;
+}
+
Modified: webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/InOutClient.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/InOutClient.cpp?rev=406472&r1=406471&r2=406472&view=diff
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/InOutClient.cpp (original)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/client/cpp/InOutClient.cpp Sun May 14 17:18:24 2006
@@ -13,6 +13,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE */
+/* ---------------------------------------------------------------- */
+/* CHANGES TO THIS FILE MAY ALSO REQUIRE CHANGES TO THE */
+/* C-EQUIVALENT FILE. PLEASE ENSURE THAT IT IS DONE. */
+/* ---------------------------------------------------------------- */
+/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
/*
Perform a variety of tests.
@@ -40,6 +49,12 @@
char endpoint[256];
const char* url="http://localhost:80/axis/InOut";
+ static char* str1 = "Apache";
+ static char* str2 = "Axis C++";
+
+ int x = 0;
+ int npr;
+
if(argc>1)
url = argv[1];
@@ -48,20 +63,13 @@
sprintf(endpoint, "%s", url);
InOut ws(endpoint);
- xsd__int_Array int_in;
- xsd__double_Array double_in;
- xsd__string_Array string_in;
-
- static char* str1 = "Apache";
- static char* str2 = "Axis C++";
-
cout << "noParametersNoReturn" << endl;
ws.noParametersNoReturn();
cout << "noParametersNoReturn returned" << endl;
cout << "noParametersIntReturn" << endl;
- int npir = ws.noParametersIntReturn();
- cout << "noParametersIntReturn returned " << npir << endl;
+ npr = ws.noParametersIntReturn();
+ cout << "noParametersIntReturn returned " << npr << endl;
cout << "multiParametersNoReturn" << endl;
ws.multiParametersNoReturn("Hey dude", 69, (xsd__double)17.19);
@@ -80,28 +88,31 @@
//...........................................................
- xsd__int ** arrayOfInt = new xsd__int*[3];
+ xsd__int * arrayOfInt[3];
xsd__int_Array intArray;
+ xsd__string_Array stringArray;
+ xsd__string arrayOfString[3];
+
+ ComplexType1 ct;
+
arrayOfInt[0] = new xsd__int(37);
arrayOfInt[1] = new xsd__int(0);
arrayOfInt[2] = new xsd__int(43);
intArray.set(arrayOfInt,3);
- xsd__string_Array stringArray;
- xsd__string * arrayOfString =new xsd__string[3];
arrayOfString[0]="One";
arrayOfString[1]="Two";
arrayOfString[2]="Three";
stringArray.set(arrayOfString,3);
- ComplexType1 ct;
+
ct.ctLong = (xsd__long)87654321;
ct.ctString = "World";
ct.setctIntArray(&intArray);
cout << "multiComplexParametersIntReturn" << endl;
- int mcpir = ws.multiComplexParametersIntReturn("Hello", &ct, 27, 13.31, &stringArray);
- cout << "multiComplexParametersIntReturn returned " << mcpir << endl;
+ npr = ws.multiComplexParametersIntReturn("Hello", &ct, 27, 13.31, &stringArray);
+ cout << "multiComplexParametersIntReturn returned " << npr << endl;
//test multiComplexParametersMultiComplexReturn
@@ -111,10 +122,10 @@
xsd__double outValue33 = 0;
cout << "multiComplexParametersMultiComplexReturn" << endl;
- ws.multiComplexParametersMultiComplexReturn("Hello", &ct, 27, 13.31, &stringArray, &OutValue0, &OutValue1,
- &outValue22, &outValue33);
- cout << "multiComplexParametersMultiComplexReturn returned " << OutValue0 << " , " << OutValue1->ctString <<
- endl;
+ ws.multiComplexParametersMultiComplexReturn("Hello", &ct, 27, 13.31, &stringArray,
+ &OutValue0, &OutValue1, &outValue22, &outValue33);
+ cout << "multiComplexParametersMultiComplexReturn returned " << OutValue0 << " , "
+ << OutValue1->ctString << endl;
//..............................................................................
@@ -124,18 +135,15 @@
arrayOfString[2]="Six";
stringArray.set(arrayOfString,3);
-
ComplexNilType1 cnt;
- xsd__long * longValue = new xsd__long(87654321);
- cnt.ctLong = longValue;
+ xsd__long longValue = 87654321;
+ cnt.ctLong = &longValue;
cnt.ctString = NULL;
cnt.setctIntArray(&intArray);
cout << "multiComplexParametersNilIntReturn" << endl;
- mcpir = ws.multiComplexParametersNilIntReturn(NULL, &cnt, NULL, NULL, &stringArray);
- cout << "multiComplexParametersNilIntReturn returned " << mcpir << endl;
-
- delete longValue;
+ npr = ws.multiComplexParametersNilIntReturn(NULL, &cnt, NULL, NULL, &stringArray);
+ cout << "multiComplexParametersNilIntReturn returned " << npr << endl;
/* Commented out as there is a bug in WSDL2Ws.
* AXISCPP-565 is the Jira against this problem.
@@ -149,36 +157,41 @@
* Removed from WSDL for time being.
*/
- xsd__int ** arrayOfInt2 = new xsd__int*[ARRAYSIZE];
- int x = 0;
+
+ xsd__int_Array int_in;
+ xsd__double_Array double_in;
+ xsd__string_Array string_in;
+
+ xsd__double * arrayOfDouble[ARRAYSIZE];
+ xsd__int * arrayOfInt2[ARRAYSIZE];
+ xsd__string arrayOfString2[ARRAYSIZE];
+
for (x=0; x<ARRAYSIZE; x++)
arrayOfInt2[x] = new xsd__int(x+1);
-
int_in.set(arrayOfInt2,ARRAYSIZE);
- xsd__double ** arrayOfDouble = new xsd__double*[ARRAYSIZE];
-
for (x=0; x<ARRAYSIZE; x++)
arrayOfDouble[x] = new xsd__double((xsd__double)x+71.15656);
-
double_in.set(arrayOfDouble,ARRAYSIZE);
- xsd__string * arrayOfString2 = new xsd__string[ARRAYSIZE];
arrayOfString2[0] = str1;
arrayOfString2[1] = str2;
string_in.set(arrayOfString2,ARRAYSIZE);
+
cout << "multiArrayParametersIntReturn" << endl;
- int mapir = ws.multiArrayParametersIntReturn(&int_in, &double_in, &string_in);
- cout << "multiArrayParametersIntReturn returned " << mapir << endl;
+ npr = ws.multiArrayParametersIntReturn(&int_in, &double_in, &string_in);
+ cout << "multiArrayParametersIntReturn returned " << npr << endl;
+
ComplexType2 ct2;
ct2.ctLong = (xsd__long)98765432;
ct2.setctIntArray(&intArray);
ct2.ctString = "Complex2";
ct2.ctComplex = &ct;
+ ComplexType2* ctr;
cout << "complexParameterComplexReturn" << endl;
- ComplexType2* ctr = ws.complexParameterComplexReturn(&ct2);
+ ctr = ws.complexParameterComplexReturn(&ct2);
cout << "complexParameterComplexReturn returned " << ctr->ctString << endl;
ct2.ctLong = (xsd__long)22222222;
Added: webservices/axis/trunk/c/tests/auto_build/testcases/tests/InOutC.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/tests/auto_build/testcases/tests/InOutC.xml?rev=406472&view=auto
==============================================================================
--- webservices/axis/trunk/c/tests/auto_build/testcases/tests/InOutC.xml (added)
+++ webservices/axis/trunk/c/tests/auto_build/testcases/tests/InOutC.xml Sun May 14 17:18:24 2006
@@ -0,0 +1,16 @@
+<test>
+ <name>InOutC</name>
+ <description>InOutC</description>
+ <clientLang>c</clientLang>
+ <clientCode>InOutClient.c</clientCode>
+ <wsdl>InOut.wsdl</wsdl>
+ <expected>
+ <output>
+ InOut.expected
+ </output>
+ <serverResponse>
+ InOut_ServerResponse.expected
+ </serverResponse>
+ </expected>
+ <endpoint>http://localhost:80/axis/InOut</endpoint>
+</test>