You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pr...@apache.org on 2006/04/28 12:40:01 UTC
svn commit: r397847 - in /webservices/axis/trunk/c: ./ samples/client/array/
samples/client/base/ samples/client/bench/ samples/client/doclitfault/
samples/client/element/ samples/client/enumeration/ samples/client/groupB/
samples/client/ref/ samples/c...
Author: prestonf
Date: Fri Apr 28 03:39:58 2006
New Revision: 397847
URL: http://svn.apache.org/viewcvs?rev=397847&view=rev
Log:
Changes to Client sample applications for the new memory model and to tidy up any warnings.
Modified:
webservices/axis/trunk/c/buildSamples.xml
webservices/axis/trunk/c/samples/client/array/Client.cpp
webservices/axis/trunk/c/samples/client/base/Client.cpp
webservices/axis/trunk/c/samples/client/bench/Client.cpp
webservices/axis/trunk/c/samples/client/doclitfault/Client.cpp
webservices/axis/trunk/c/samples/client/element/Client.cpp
webservices/axis/trunk/c/samples/client/enumeration/Client.cpp
webservices/axis/trunk/c/samples/client/groupB/Client.cpp
webservices/axis/trunk/c/samples/client/ref/Client.cpp
webservices/axis/trunk/c/samples/client/rpcfault/Client.cpp
webservices/axis/trunk/c/samples/client/transportProperties/Client.cpp
Modified: webservices/axis/trunk/c/buildSamples.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/buildSamples.xml?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/buildSamples.xml (original)
+++ webservices/axis/trunk/c/buildSamples.xml Fri Apr 28 03:39:58 2006
@@ -140,7 +140,7 @@
<target name="compileSamples">
<!-- <for list="array,base,bench,calculator,doclitfault,element,enumeration,groupB,ref,rpcfault,transportProperties" param="samplename">
-->
- <for list="calculator" param="samplename">
+ <for list="array,base,bench,calculator,doclitfault,element,enumeration,ref,rpcfault,transportProperties" param="samplename">
<sequential>
<property name="clientSampleDir" value="client"/>
Modified: webservices/axis/trunk/c/samples/client/array/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/array/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/array/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/array/Client.cpp Fri Apr 28 03:39:58 2006
@@ -1,133 +1,126 @@
#include "SimpleTypeArrayWS.hpp"
-#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
#include <iostream>
-#include <fstream>
#define WSDL_DEFAULT_ENDPOINT "http://localhost:80/axis/array"
-static void
-usage (char *programName, char *defaultURL)
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL << endl;
+ cout << endl << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl;
}
-
-// If we re-direct cout it will be to this ofstream
-ofstream output_file;
-
-int
-main (int argc, char *argv[])
+int main( int argc, char *argv[])
{
- SimpleTypeArrayWS *ws;
-
- char endpoint[256];
- sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
+ SimpleTypeArrayWS * ws;
+ char endpoint[256];
+ int returnValue = 1; // Assume Failure
+ bool bSuccess = false;
+ int iRetryIterationCount = 3;
- int returnValue = 1; // Assume Failure
+ sprintf( endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
- bool bSuccess = false;
- int iRetryIterationCount = 3;
-
- if (argc > 1)
+ if( argc > 1)
{
- // Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
- {
- usage (argv[0], endpoint);
- return 2;
- }
- sprintf (endpoint, argv[1]);
+// Watch for special case help request
+// Check for - only so that it works for
+//-?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
+ {
+ usage( argv[0], endpoint);
+ return 2;
+ }
+
+ sprintf( endpoint, argv[1]);
}
+
do
{
- ws = new SimpleTypeArrayWS (endpoint, APTHTTP1_1);
- try
- {
-
- Type *input;
- Type *output;
- xsd__int_Array array_input;
- int entries[100];
- int i;
-
- array_input.m_Array = new int *[100];
- array_input.m_Size = 100;
-
- for (i = 0; i < 100; i++)
- {
- entries[i] = i;
- array_input.m_Array[i] = &entries[i];
- }
-
- input = new Type ();
- input->item = array_input;
-
- ws->setTransportProperty ("SOAPAction", "array#getInput");
- output = ws->getInput (input);
-
- for (i = 0; i < 100; i++)
- {
- cout << "item [" << i << "] = " << *(output->item.
- m_Array[i]) << endl;
- }
- returnValue = 0; // Success
-
- bSuccess = true;
- }
- catch (AxisException & e)
- {
- bool bSilent = false;
-
- if (e.getExceptionCode () ==
- CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
- {
- if (iRetryIterationCount > 0)
- {
- bSilent = true;
- }
- }
- else
- {
- iRetryIterationCount = 0;
- }
-
- if (!bSilent)
- {
- cerr << e.what () << endl;
- }
- //if(endpoint_set)
- free (endpoint);
- }
- catch (...)
- {
- cerr << "Unknown Exception occured." << endl;
- }
-
- // clean up
- try
- {
- delete ws;
- }
- catch (exception & exception)
- {
- cerr << "Exception on clean up of ws : " << exception.
- what () << endl;
- }
- catch (...)
- {
- cerr << "Unknown exception on clean up of ws : " << endl;
- }
- iRetryIterationCount--;
- }
- while (iRetryIterationCount > 0 && !bSuccess);
- cout <<
- "---------------------- TEST COMPLETE -----------------------------"
- << endl;
- return returnValue;
+ ws = new SimpleTypeArrayWS( endpoint, APTHTTP1_1);
+
+ try
+ {
+ Type * input;
+ Type * output;
+ xsd__int_Array array_input;
+ int iIntArraySize = 100;
+ xsd__int ** ppIntArray = new xsd__int *[iIntArraySize];
+
+ for( int i = 0; i < 100; i++)
+ {
+ (*ppIntArray)[i] = i;
+ }
+
+ array_input.set( ppIntArray, iIntArraySize);
+
+
+ input = new Type ();
+ input->item = &array_input;
+
+ ws->setTransportProperty( "SOAPAction", "array#getInput");
+ output = ws->getInput( input);
+
+ xsd__int_Array * array_output = output->getitem();
+ int iSize;
+ const xsd__int ** ppArray = array_output->get( iSize);
+
+ for( int i = 0; i < iSize; i++)
+ {
+ cout << "item [" << i << "] = " << *ppArray[i] << endl;
+ }
+
+ returnValue = 0; // Success
+
+ bSuccess = true;
+ }
+ catch( AxisException & e)
+ {
+ bool bSilent = false;
+
+ if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
+ {
+ if( iRetryIterationCount > 1)
+ {
+ bSilent = true;
+ }
+ }
+ else
+ {
+ iRetryIterationCount = 0;
+ }
+
+ if( !bSilent)
+ {
+ cerr << e.what() << endl;
+ }
+
+ free( endpoint);
+ }
+ catch( ...)
+ {
+ cerr << "Unknown Exception occured." << endl;
+ }
+
+ // clean up
+ try
+ {
+ delete ws;
+ }
+ catch( exception & exception)
+ {
+ cerr << "Exception on clean up of ws : " << exception.what() << endl;
+ }
+ catch( ...)
+ {
+ cerr << "Unknown exception on clean up of ws : " << endl;
+ }
+
+ iRetryIterationCount--;
+ } while( iRetryIterationCount > 0 && !bSuccess);
+
+ cout << "---------------------- TEST COMPLETE -----------------------------" << endl;
+ return returnValue;
}
Modified: webservices/axis/trunk/c/samples/client/base/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/base/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/base/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/base/Client.cpp Fri Apr 28 03:39:58 2006
@@ -16,338 +16,412 @@
// InteropBaseClient.cpp : Defines the entry point for the console application.
//
#include <string>
-#include <iostream>
+//#include <iostream>
using namespace std;
#include "InteropTestPortType.hpp"
#define ARRAYSIZE 2
-static void
-usage (char *programName, char *defaultURL)
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL << endl;
+ cout << endl << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl;
}
-
-int
-main (int argc, char *argv[])
+int main( int argc, char *argv[])
{
- int x = 0;
- int i = 0;
- char buffer1[100];
- char endpoint[256];
- const char *server = "localhost";
- const char *port = "80";
- sprintf (endpoint, "http://%s:%s/axis/base", server, port);
+ int x = 0;
+ int i = 0;
+ char buffer1[100];
+ char endpoint[256];
+ const char * server = "localhost";
+ const char * port = "80";
+
+ sprintf( endpoint, "http://%s:%s/axis/base", server, port);
- if (argc > 1)
+ if( argc > 1)
{
- // Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
- {
- usage (argv[0], endpoint);
- return 2;
+// Watch for special case help request
+// Check for - only so that it works for
+//-?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
+ {
+ usage( argv[0], endpoint);
+
+ return 2;
+ }
+
+ sprintf( endpoint, argv[1]);
}
- sprintf (endpoint, argv[1]);
- }
- bool bSuccess = false;
- int iRetryIterationCount = 3;
+ bool bSuccess = false;
+ int iRetryIterationCount = 3;
do
{
- try
- {
- InteropTestPortType ws (endpoint, APTHTTP1_1);
-
- //testing echoString
- printf ("invoking echoString...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoString");
- string bigstring;
- for (int ii = 0; ii < 2; ii++)
- {
- bigstring += "hello world ";
- }
- strcpy (buffer1, bigstring.c_str ());
-
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoString");
-
- char* cpResult = ws.echoString ("hello world");
- if (0 == strcmp (cpResult, "hello world"))
- printf ("successful\n");
- else
- printf ("failed\n");
-
- delete [] cpResult;
-
- // testing echoStringArray
- xsd__string_Array arrstr;
- arrstr.m_Array = new char *[ARRAYSIZE];
- arrstr.m_Size = ARRAYSIZE;
- sprintf (buffer1, "%dth element of string array", 0);
- for (i = 0; i < ARRAYSIZE; i++)
- {
- arrstr.m_Array[i] = buffer1;
- }
-
- ws.setTransportProperty ("SOAPAction",
- "InteropBase#echoStringArray");
- printf ("invoking echoStringArray...\n");
-
- char** arrstrResult = ws.echoStringArray (arrstr).m_Array;
-
- if (arrstrResult != NULL)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- delete [] arrstr.m_Array;
- for (i = 0; i < ARRAYSIZE; i++)
- {
- delete [] arrstrResult[i];
- }
-
- delete [] arrstrResult;
-
- // testing echoInteger
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoInteger");
- printf ("invoking echoInteger...\n");
- if (ws.echoInteger (56) == 56)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- // testing echoIntegerArray
- xsd__int_Array arrint;
- arrint.m_Array = new int *[ARRAYSIZE];
- arrint.m_Size = ARRAYSIZE;
- int iToSend[ARRAYSIZE];
-
- for (x = 0; x < ARRAYSIZE; x++)
- {
- iToSend[x] = x;
- arrint.m_Array[x] = &iToSend[x];
- }
- ws.setTransportProperty ("SOAPAction",
- "InteropBase#echoIntegerArray");
- printf ("invoking echoIntegerArray...\n");
- xsd__int_Array arrintResult = ws.echoIntegerArray (arrint);
- if (arrintResult.m_Array != NULL)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- delete [] arrint.m_Array;
- // Free memory for result
- for (x = 0; x < arrintResult.m_Size; x++)
- delete arrintResult.m_Array[x];
-
- delete [] arrintResult.m_Array;
-
- // testing echoFloat
- printf ("invoking echoFloat...\n");
- float fvalue = 1.4214;
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoFloat");
- if (ws.echoFloat (fvalue) > 1.42)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- // testing echoFloat
- xsd__float_Array arrfloat;
- arrfloat.m_Array = new float *[ARRAYSIZE];
- arrfloat.m_Size = ARRAYSIZE;
- float fToSend[ARRAYSIZE];
- for (x = 0; x < ARRAYSIZE; x++)
- {
- fToSend[x] = 1.1111 * x;
- arrfloat.m_Array[x] = &fToSend[x];
- }
- ws.setTransportProperty ("SOAPAction",
- "InteropBase#echoFloatArray");
- printf ("invoking echoFloatArray...\n");
- xsd__float_Array arrfloatResult = ws.echoFloatArray (arrfloat);
- if (arrfloatResult.m_Array != NULL)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- delete [] arrfloat.m_Array;
-
- for (x = 0; x < arrfloatResult.m_Size; x++)
- delete arrfloatResult.m_Array[x];
- delete [] arrfloatResult.m_Array;
-
- // testing echo Struct
- SOAPStruct stct;
- xsd__int integer = 5000;
- xsd__float floatVal = 12345.7346345;
- stct.varFloat = &floatVal;
- stct.varInt = &integer;
- stct.varString = strdup ("This is string in SOAPStruct");
- printf ("invoking echoStruct...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoStruct");
- SOAPStruct *stctResult = ws.echoStruct (&stct);
- if (stctResult != NULL)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- // Free parameter memeory
- free(stct.varString);
-
- // Free result memory
- delete [] stctResult->varString;
- delete stctResult->varInt;
- delete stctResult->varFloat;
- delete stctResult;
-
- //testing echo Array of Struct
- SOAPStruct_Array arrstct;
- arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
- arrstct.m_Size = ARRAYSIZE;
- for (x = 0; x < ARRAYSIZE; x++)
- {
- integer = x;
- floatVal = 1.1111 * x;
- arrstct.m_Array[x].varFloat = &floatVal;
- arrstct.m_Array[x].varInt = &integer;
- sprintf (buffer1,
- "varString of %dth element of SOAPStruct array", x);
- arrstct.m_Array[x].varString = buffer1;
- }
-
- //testing echo Struct Array
- ws.setTransportProperty ("SOAPAction",
- "InteropBase#echoStructArray");
- printf ("invoking echoStructArray...\n");
- SOAPStruct_Array arrstctResult = ws.echoStructArray (arrstct);
- if (arrstctResult.m_Array != NULL)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- delete [] arrstct.m_Array;
- for( x = 0; x < arrstctResult.m_Size; x++)
+ try
{
- delete [] arrstctResult.m_Array[x].varString;
- delete arrstctResult.m_Array[x].varInt;
- delete arrstctResult.m_Array[x].varFloat;
- }
- delete [] arrstctResult.m_Array;
-
- //testing echo void
- printf ("invoking echoVoid...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoVoid");
- ws.echoVoid ();
- printf ("successful\n");
-
- //testing echo base 64 binary
- const char *bstr =
- "some string that is sent encoded to either base64Binary or hexBinary";
-
- printf ("invoking echoBase64...\n");
- xsd__base64Binary bb;
- bb.__ptr = (unsigned char *) strdup (bstr);
- bb.__size = strlen (bstr);
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoBase64");
- xsd__base64Binary bbResult = ws.echoBase64 (bb);
- if (bb.__size == bbResult.__size)
- {
- printf ("successful\n");
- printf ("Returned String :\n%s\n", bbResult.__ptr);
- }
- else
- printf ("failed\n");
-
- free(bb.__ptr);
- delete [] bbResult.__ptr;
-
- time_t tim;
- time (&tim);
- tm *lt = gmtime (&tim);
- printf ("invoking echoDate...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoDate");
- if (memcmp (&ws.echoDate (*lt), lt, sizeof (tm)) == 0)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- //testing echo hex binary
- printf ("invoking echoHexBinary...\n");
- xsd__hexBinary hb;
- hb.__ptr = (unsigned char *) strdup (bstr);
- hb.__size = strlen (bstr);
- ws.setTransportProperty ("SOAPAction",
- "InteropBase#echoHexBinary");
- xsd__hexBinary hbReturn = ws.echoHexBinary (hb);
- if (hb.__size == hbReturn.__size)
- {
- printf ("successful\n");
- printf ("Returned String :\n%s\n", hbReturn.__ptr);
- }
- else
- printf ("failed\n");
-
- free(hb.__ptr);
- delete [] hbReturn.__ptr;
- //testing echo decimal
- printf ("invoking echoDecimal...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoDecimal");
- if (ws.echoDecimal (1234.567890) > 1234.56)
- printf ("successful\n");
- else
- printf ("failed\n");
-
- //testing echo boolean
- printf ("invoking echoBoolean...\n");
- ws.setTransportProperty ("SOAPAction", "InteropBase#echoBoolean");
- if (ws.echoBoolean (true_) == true_)
- printf ("successful\n");
- else
- printf ("failed\n");
+ InteropTestPortType ws( endpoint, APTHTTP1_1);
- bSuccess = true;
- }
- catch (AxisException & e)
- {
- bool bSilent = false;
-
- if (e.getExceptionCode () ==
- CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
- {
- if (iRetryIterationCount > 0)
+//testing echoString
+ cout << "invoking echoString..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoString");
+
+ string bigstring;
+
+ for( int ii = 0; ii < 2; ii++)
+ {
+ bigstring += "hello world ";
+ }
+
+ strcpy( buffer1, bigstring.c_str());
+
+ char * cpResult = ws.echoString( "hello world");
+
+ if( 0 == strcmp( cpResult, "hello world"))
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ delete [] cpResult;
+
+// testing echoStringArray
+ cout << "invoking echoStringArray..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoStringArray");
+
+ xsd__string * pStringArray = new char *[ARRAYSIZE];
+ xsd__string_Array arrstr;
+
+ sprintf( buffer1, "%dth element of string array", 0);
+
+ for( i = 0; i < ARRAYSIZE; i++)
+ {
+ pStringArray[i] = buffer1;
+ }
+
+ arrstr.set( pStringArray, ARRAYSIZE);
+
+ xsd__string_Array * arrstrResult = ws.echoStringArray( &arrstr);
+
+ if( arrstrResult != NULL)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ delete [] arrstrResult;
+
+// testing echoInteger
+ cout << "invoking echoInteger..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoInteger");
+
+ if( ws.echoInteger( 56) == 56)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+// testing echoIntegerArray
+ cout << "invoking echoIntegerArray..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoIntegerArray");
+
+ xsd__int ** ppIntArray = new xsd__int *[ARRAYSIZE];
+ xsd__int_Array arrint;
+ int iToSend[ARRAYSIZE];
+
+ for( x = 0; x < ARRAYSIZE; x++)
+ {
+ iToSend[x] = x;
+ ppIntArray[x] = (xsd__int *) &iToSend[x];
+ }
+
+ arrint.set( ppIntArray, ARRAYSIZE);
+
+ xsd__int_Array * arrintResult = ws.echoIntegerArray( &arrint);
+ int iSize;
+ const xsd__int ** ppIntOutputArray = arrintResult->get( iSize);
+
+ if( ppIntOutputArray != NULL)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ // Free memory for result
+ delete [] arrintResult;
+
+// testing echoFloat
+ cout << "invoking echoFloat..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoFloat");
+
+ xsd__float fvalue = (xsd__float) 1.4214;
+
+ if (ws.echoFloat (fvalue) > (xsd__float) 1.42)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+// testing echoFloat
+ cout << "invoking echoFloatArray..." << endl;
+
+ ws.setTransportProperty ( "SOAPAction", "InteropBase#echoFloatArray");
+
+ xsd__float_Array arrfloat;
+ xsd__float ** ppFloatArray = new xsd__float *[ARRAYSIZE];
+ xsd__float fToSend[ARRAYSIZE];
+
+ for( x = 0; x < ARRAYSIZE; x++)
+ {
+ fToSend[x] = (xsd__float) 1.1111 * x;
+ ppFloatArray[x] = &fToSend[x];
+ }
+
+ arrfloat.set( ppFloatArray, ARRAYSIZE);
+
+ xsd__float_Array * arrfloatResult = ws.echoFloatArray( &arrfloat);
+
+ if( arrfloatResult != NULL)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ delete [] ppFloatArray;
+ delete [] arrfloatResult;
+
+// testing echo Struct
+ cout << "invoking echoStruct..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoStruct");
+
+ SOAPStruct stct;
+ xsd__int integer = 5000;
+ xsd__float floatVal = (xsd__float) 12345.7346345;
+
+ stct.varFloat = &floatVal;
+ stct.varInt = &integer;
+ stct.varString = strdup( "This is string in SOAPStruct");
+
+ SOAPStruct *stctResult = ws.echoStruct( &stct);
+
+ if (stctResult != NULL)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ // Free result memory
+ delete stctResult;
+
+//testing echo Array of Struct
+ SOAPStruct_Array arrstct;
+ SOAPStruct ** ppSOAPStruct = new SOAPStruct* [ARRAYSIZE];
+
+ for( x = 0; x < ARRAYSIZE; x++)
+ {
+ integer = x;
+ floatVal = (xsd__float) 1.1111 * x;
+
+ sprintf( buffer1, "varString of %dth element of SOAPStruct array", x);
+
+ ppSOAPStruct[x]->setvarFloat( &floatVal);
+ ppSOAPStruct[x]->setvarInt( &integer);
+ ppSOAPStruct[x]->setvarString( buffer1);
+ }
+
+ arrstct.set( ppSOAPStruct, ARRAYSIZE);
+
+//testing echo Struct Array
+ cout << "invoking echoStructArray..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoStructArray");
+
+ SOAPStruct_Array * arrstctResult = ws.echoStructArray( &arrstct);
+
+ if( arrstctResult != NULL)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ delete ppSOAPStruct;
+ delete [] arrstctResult;
+
+//testing echo void
+ cout << "invoking echoVoid..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoVoid");
+
+ ws.echoVoid();
+
+ cout << "successful" << endl;
+
+//testing echo base 64 binary
+ cout << "invoking echoBase64..." << endl;
+
+ ws.setTransportProperty ("SOAPAction", "InteropBase#echoBase64");
+
+ const char * bstr = "some string that is sent encoded to either base64Binary or hexBinary";
+
+ xsd__base64Binary bb;
+
+ bb.set( (xsd__unsignedByte *) strdup( bstr), (xsd__int) strlen( bstr));
+
+ xsd__base64Binary bbResult = ws.echoBase64( bb);
+
+ if( (xsd__int) strlen( bstr) == bbResult.getSize())
+ {
+ xsd__int iSize;
+
+ cout << "successful" << endl
+ << "Returned String :" << endl
+ << bbResult.get( iSize) << endl;
+ }
+ else
+ {
+ printf ("failed\n");
+ }
+
+ cout << "invoking echoDate..." << endl;
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoDate");
+
+ time_t tim;
+
+ time( &tim);
+
+ tm * lt = gmtime( &tim);
+
+ if( memcmp( &ws.echoDate( *lt), lt, sizeof( tm)) == 0)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+//testing echo hex binary
+ cout << "invoking echoHexBinary..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoHexBinary");
+
+ xsd__hexBinary hb;
+
+ iSize = (xsd__int) strlen( bstr);
+
+ hb.set( (xsd__unsignedByte *) strdup( bstr), iSize);
+
+ xsd__hexBinary hbReturn = ws.echoHexBinary( hb);
+
+ if( iSize == hbReturn.getSize())
+ {
+ cout << "successful" << endl
+ << "Returned String :" << endl
+ << hbReturn.get( iSize) << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+//testing echo decimal
+ cout << "invoking echoDecimal..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoDecimal");
+
+ if( ws.echoDecimal( 1234.567890) > 1234.56)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ //testing echo boolean
+ cout << "invoking echoBoolean..." << endl;
+
+ ws.setTransportProperty( "SOAPAction", "InteropBase#echoBoolean");
+
+ if( ws.echoBoolean (true_) == true_)
+ {
+ cout << "successful" << endl;
+ }
+ else
+ {
+ cout << "failed" << endl;
+ }
+
+ bSuccess = true;
+ }
+ catch( AxisException & e)
{
- bSilent = true;
+ bool bSilent = false;
+
+ if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
+ {
+ if( iRetryIterationCount > 1)
+ {
+ bSilent = true;
+ }
+ }
+ else
+ {
+ iRetryIterationCount = 0;
+ }
+
+ if( !bSilent)
+ {
+ cout << e.what() << endl;
+ }
}
- }
- else
- {
- iRetryIterationCount = 0;
- }
-
- if (!bSilent)
- {
- printf ("%s\n", e.what ());
- }
- }
- catch (exception & e)
- {
- printf ("%s\n", e.what ());
- }
- catch (...)
- {
- printf ("Unknown exception has occured\n");
- }
- iRetryIterationCount--;
- }
- while (iRetryIterationCount > 0 && !bSuccess);
+ catch( exception & e)
+ {
+ cout << e.what() << endl;
+ }
+ catch( ...)
+ {
+ cout << "Unknown exception has occured" << endl;
+ }
+
+ iRetryIterationCount--;
+ } while( iRetryIterationCount > 0 && !bSuccess);
+
//getchar();
return 0;
}
Modified: webservices/axis/trunk/c/samples/client/bench/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/bench/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/bench/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/bench/Client.cpp Fri Apr 28 03:39:58 2006
@@ -1,299 +1,296 @@
#include "AxisBench.hpp"
#include <iostream>
-#include <fstream>
#include <time.h>
#ifndef WIN32
#include "sys/time.h"
#else
#include "sys/timeb.h"
+#endif
+
+#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
+#include <iostream>
// Bug in MS Visual C++ 6.0. Fixed in Visual C++ .Net version.
// Cannot print an __int64 number with cout without this overloading
-std::ostream & operator<< (std::ostream & os, __int64 i)
+std::ostream & operator << (std::ostream & os, __int64 i)
{
- char buf[20];
- sprintf (buf, "%I64d", i);
- os << buf;
- return os;
-}
+ char buf[20];
-#endif
+ sprintf( buf, "%I64d", i);
-static bool verbose = false;
-#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
+ os << buf;
-// If we re-direct cout it will be to this ofstream
-ofstream output_file;
+ return os;
+}
#define WSDL_DEFAULT_ENDPOINT "http://localhost:80/axis/bench"
-static void
-usage (char *programName, char *defaultURL)
+static char * asciiToString( char * string);
+
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL << endl;
+ cout << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl;
}
-int
-main (int argc, char *argv[])
+int main( int argc, char * argv[])
{
- AxisBench *ws;
-
- BenchDataType *input = NULL;
- BenchDataType *output = NULL;
- xsd__unsignedByte *buffer = NULL;
+ char endpoint[256];
+ int returnValue = 1; // Assume Failure
+ bool bSuccess = false;
+ int iRetryIterationCount = 3;
+ AxisBench * ws = NULL;
+ BenchDataType * input = NULL;
+ BenchDataType * output = NULL;
- char endpoint[256];
- sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
- int returnValue = 1; // Assume Failure
+ sprintf( endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
-
- bool bSuccess = false;
- int iRetryIterationCount = 3;
- if (argc > 1)
+ if( argc > 1)
{
// Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
- {
- usage (argv[0], endpoint);
- return 2;
- }
- sprintf (endpoint, argv[1]);
- }
- do
- {
- try
- {
- ws = new AxisBench (endpoint, APTHTTP1_1);
+ // Check for - only so that it works for
+ //-?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
+ {
+ usage( argv[0], endpoint);
+
+ return 2;
+ }
+ sprintf( endpoint, argv[1]);
+ }
- int request = 1;
+ do
+ {
+ try
+ {
+ int request = 1;
+
+ input = new BenchDataType();
+ ws = new AxisBench( endpoint, APTHTTP1_1);
- input = new BenchDataType ();
- input->count = 10;
+ input->setcount( (xsd__int) 10);
- BenchBasicDataType **ppBBDT =
- (BenchBasicDataType **) new BenchBasicDataType*[input->count];
+ BenchBasicDataType ** ppBBDT = new BenchBasicDataType* [input->getcount()];
+ BenchBasicDataType_Array arrayIn;
#ifdef WIN32
- __int64 ll = 10000;
+ __int64 ll = 10000;
#else
- long long ll = 10000;
+ long long ll = 10000;
#endif
- input->infos.m_Array = ppBBDT;
+ time_t tim;
- input->infos.m_Size = input->count;
+ tim = 1100246323;
- time_t tim;
- tim = 1100246323;
- struct tm *temp = gmtime (&tim);
- struct tm lt;
- memcpy (<, temp, sizeof (struct tm));
+ struct tm * temp = gmtime( &tim);
+ struct tm lt;
+ memcpy( <, temp, sizeof( struct tm));
- buffer = (xsd__unsignedByte *) calloc (1, input->count + 2);
- strcpy ((char *) buffer, "A");
+ xsd__unsignedByte * buffer = (xsd__unsignedByte *) calloc( 1, input->getcount() + 2);
- for (int i = 0; i < input->count; i++)
- {
- BenchBasicDataType *type = new BenchBasicDataType ();
- type->StringType = "StringType";
- type->IntegerType = 10 * (i + 1);
- type->DoubleType = 11.111 * (i + 1);
- type->BooleanType = true_;
- type->DateTimeType = lt;
- type->TimeType = lt;
- type->DateType = lt;
- type->IntType = (i + 1);
- type->ByteType = '1';
- type->DecimalType = 10 * (i + 1);
- type->FloatType =
- (float) ((float) (11 * (i + 1)) / (float) 2.0);
- type->LongType = ll;
- type->QNameType = "toto";
- type->ShortType = (i + 1);
- type->Base64BinaryType.__size = i;
- type->Base64BinaryType.__ptr = buffer;
- type->HexBinary.__size = i;
- type->HexBinary.__ptr = buffer;
+ strcpy( (char *) buffer, "A");
- if (i == 90)
- {
- *ppBBDT = type;
- }
- else
- {
- *ppBBDT = type;
- }
+ for( int i = 0; i < (int) input->getcount(); i++)
+ {
+ BenchBasicDataType * type = new BenchBasicDataType();
- ppBBDT++;
+ type->StringType = "StringType";
+ type->IntegerType = 10 * (i + 1);
+ type->DoubleType = 11.111 * (i + 1);
+ type->BooleanType = true_;
+ type->DateTimeType = lt;
+ type->TimeType = lt;
+ type->DateType = lt;
+ type->IntType = (i + 1);
+ type->ByteType = '1';
+ type->DecimalType = 10 * (i + 1);
+ type->FloatType = (float) ((float) (11 * (i + 1)) / (float) 2.0);
+ type->LongType = ll;
+ type->QNameType = "toto";
+ type->ShortType = (i + 1);
+ type->Base64BinaryType.set( (xsd__unsignedByte *) buffer, (xsd__int) i);
+ type->HexBinary.set( (xsd__unsignedByte *) buffer, (xsd__int) i);
+
+ *ppBBDT = type;
+
+ ppBBDT++;
+
+ if( ll == 0)
+ {
+ ll = 1;
+ }
+ else
+ {
+ ll += 10000;
+ }
- if (ll == 0)
- {
- ll = 1;
- }
- else
- {
- ll += 10000;
- }
+ strcat( (char *) buffer, "A");
+ }
- strcat ((char *) buffer, "A");
- }
+ arrayIn.set( ppBBDT, (int) input->getcount());
+
+ input->setinfos( &arrayIn);
+
+ int t1;
+ int t2;
- int t1, t2;
#ifndef WIN32
- struct timeval mstart;
- struct timeval mstop;
- gettimeofday (&mstart, NULL);
+ struct timeval mstart;
+ struct timeval mstop;
+
+ gettimeofday( &mstart, NULL);
#else
- struct timeb mstart;
- struct timeb mstop;
- ftime (&mstart);
+ struct timeb mstart;
+ struct timeb mstop;
+ ftime( &mstart);
#endif
- for (int ii = 0; ii < request; ii++)
- {
- if (output)
- { // Samisa: memory management BP
- for (int i = 0; i < output->infos.m_Size; i++)
- delete (BenchBasicDataType *) (output->infos.
- m_Array[i]);
- delete output;
- output = NULL;
- }
- ws->setTransportProperty ("SOAPAction",
- "AxisBench#doBenchRequest");
- output = ws->doBenchRequest (input);
- }
+ ws->setTransportProperty ("SOAPAction", "AxisBench#doBenchRequest");
+
+ for( int ii = 0; ii < request; ii++)
+ {
+ if( output)
+ { // Samisa: memory management BP
+ int outputSize = 0;
+ BenchBasicDataType ** outArray = output->infos->get( outputSize);
+
+ for( int i = 0; i < outputSize; i++)
+ {
+ delete outArray[i];
+ }
+
+ delete output;
+
+ output = NULL;
+ }
- free (buffer);
+ output = ws->doBenchRequest( input);
+ }
+
+ free( buffer);
#ifndef WIN32
- gettimeofday (&mstop, NULL);
- t1 = mstart.tv_sec * 1000 + mstart.tv_usec / 1000;
- t2 = mstop.tv_sec * 1000 + mstop.tv_usec / 1000;
+ gettimeofday( &mstop, NULL);
+
+ t1 = mstart.tv_sec * 1000 + mstart.tv_usec / 1000;
+ t2 = mstop.tv_sec * 1000 + mstop.tv_usec / 1000;
#else
- ftime (&mstop);
- t1 = mstart.time * 1000 + mstart.millitm;
- t2 = mstop.time * 1000 + mstop.millitm;
+ ftime( &mstop);
+
+ t1 = mstart.time * 1000 + mstart.millitm;
+ t2 = mstop.time * 1000 + mstop.millitm;
#endif
- int total = t2 - t1;
+ int total = t2 - t1;
- if (ws->getStatus () == AXIS_FAIL)
- cout << "Failed" << endl;
- else
- {
- bSuccess = true;
- char dateTime[50];
- int i = 0;
- if (argc > 1)
- i = output->count - 1;
-
- cout << "Input Count : " << input->count << endl;
- cout << "Count : " << output->count << endl;
- for (; i < output->count; i++)
- {
- if (output->infos.m_Array[i] !=
- (BenchBasicDataType *) 0xcdcdcdcd)
- {
- cout <<
- " ----------------------------------------------"
- << endl;
- cout << " StringType " << output->infos.m_Array[i]->
- StringType << endl;
- cout << " IntType " << output->infos.m_Array[i]->
- IntType << endl;
- cout << " IntegerType " << output->infos.m_Array[i]->
- IntegerType << endl;
- cout << " DoubleType " << output->infos.m_Array[i]->
- DoubleType << endl;
- cout << " BooleanType " << output->infos.m_Array[i]->
- BooleanType << endl;
- strftime (dateTime, 50, "%a %b %d %H:%M:%S %Y",
- &output->infos.m_Array[i]->DateTimeType);
- cout << " DateTimeType " << dateTime << endl;
- strftime (dateTime, 50, "%a %b %d %Y",
- &output->infos.m_Array[i]->DateType);
- cout << " DateType " << dateTime << endl;
-// This is being removed due to problem in some servers.
-// See XSDTime or XSDTimeNil testcases for full validation of the xsd:time type
-// strftime(dateTime, 50, "%H:%M:%S", &output->infos.m_Array[i]->TimeType);
-// cout << " TimeType " << dateTime << endl;
- cout << " ByteType " << output->infos.m_Array[i]->
- ByteType << endl;
- cout << " DecimalType " << output->infos.m_Array[i]->
- DecimalType << endl;
- cout << " FloatType " << output->infos.m_Array[i]->
- FloatType << endl;
- cout << " LongType " << output->infos.m_Array[i]->
- LongType << endl;
- cout << " QNameType " << output->infos.m_Array[i]->
- QNameType << endl;
- cout << " ShortType " << output->infos.m_Array[i]->
- ShortType << endl;
-
- cout << " Base64BinaryType " << output->infos.
- m_Array[i]->Base64BinaryType.__size << endl;
- if (output->infos.m_Array[i]->Base64BinaryType.
- __size > 0)
+ if( ws->getStatus () == AXIS_FAIL)
{
- cout << " Base64BinaryType " << output->infos.
- m_Array[i]->Base64BinaryType.__ptr << endl;
+ cout << "Failed" << endl;
}
-
- cout << " HexBinaryType " << output->infos.
- m_Array[i]->HexBinary.__size << endl;
- if (output->infos.m_Array[i]->HexBinary.__size > 0)
+ else
{
- cout << " HexBinaryType " << output->infos.
- m_Array[i]->HexBinary.__ptr << endl;
+ char dateTime[50];
+ int i = 0;
+
+ bSuccess = true;
+
+ if (argc > 1)
+ {
+ i = output->count - 1;
+ }
+
+ cout << "Input Count : " << input->count << endl;
+ cout << "Count : " << output->count << endl;
+
+ for (; i < (int) output->getcount(); i++)
+ {
+ int outputSize = 0;
+ BenchBasicDataType ** outArray = output->infos->get( outputSize);
+
+ if( outArray[i] != NULL)
+ {
+ cout << " ----------------------------------------------" << endl;
+ cout << " StringType " << outArray[i]->StringType << endl;
+ cout << " IntType " << outArray[i]->IntType << endl;
+// cout << " IntegerType " << outArray[i]->IntegerType << endl;
+ cout << " DoubleType " << outArray[i]->DoubleType << endl;
+ cout << " BooleanType " << outArray[i]->BooleanType << endl;
+ strftime(dateTime, 50, "%a %b %d %H:%M:%S %Y", &outArray[i]->DateTimeType);
+ cout << " DateTimeType " << dateTime << endl;
+ strftime(dateTime, 50, "%a %b %d %Y", &outArray[i]->DateType);
+ cout << " DateType " << dateTime << endl;
+// This is being removed due to problem in some servers.
+// See XSDTime or XSDTimeNil testcases for full validation of the xsd:time type
+// strftime(dateTime, 50, "%H:%M:%S", &output->infos.m_Array[i]->TimeType);
+// cout << " TimeType " << dateTime << endl;
+
+// Following check for os/400 - the mock server will return ascii char which needs to be converted
+#ifdef __OS400__
+ if( outArray[i]->ByteType == 0x31)
+ outArray[i]->ByteType = '1';
+#endif
+ cout << " ByteType " << outArray[i]->ByteType << endl;
+ cout << " DecimalType " << outArray[i]->DecimalType << endl;
+ cout << " FloatType " << outArray[i]->FloatType << endl;
+// cout << " LongType " << outArray[i]->LongType << endl;
+ cout << " QNameType " << outArray[i]->QNameType << endl;
+ cout << " ShortType " << outArray[i]->ShortType << endl;
+
+ int size = 0;
+ xsd__unsignedByte * base64BinaryData = outArray[i]->Base64BinaryType.get( size);
+
+ cout << " Base64BinaryType " << size << endl;
+
+ if( size > 0)
+ {
+ cout << " Base64BinaryType " << asciiToString( (char *)base64BinaryData) << endl;
+ }
+
+ size = 0;
+
+ xsd__unsignedByte * hexBinaryData = outArray[i]->HexBinary.get(size);
+
+ cout << " HexBinaryType " << size << endl;
+
+ if( size > 0)
+ {
+ cout << " HexBinaryType " << asciiToString( (char *) hexBinaryData) << endl;
+ }
+ }
+ }
+
+ returnValue = 0;
}
- }
- returnValue = 0;
}
- }
-
- if (verbose)
- {
- cout << " ----------------------------------------------" <<
- endl;
- cout << input->
- count << " input paramters, and " << request <<
- " requests" << endl;
- cout << "Total time = " << total << " ms" << endl;
- cout << "Average time = " << total / request << " ms" << endl;
- }
- }
catch (AxisException & e)
{
bool bSilent = false;
- if (e.getExceptionCode () ==
- CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
+ if( e.getExceptionCode () == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
{
- if (iRetryIterationCount > 0)
- {
- bSilent = true;
- }
+ if( iRetryIterationCount > 1)
+ {
+ bSilent = true;
+ }
}
else
{
- iRetryIterationCount = 0;
+ iRetryIterationCount = 0;
}
- if (!bSilent)
+ if( !bSilent)
{
- cout << "Exception : " << e.what () << endl;
+ cout << "Exception : " << e.what () << endl;
}
}
- catch (...)
+ catch( ...)
{
cerr << "Unknown Exception occured." << endl;
}
@@ -301,22 +298,19 @@
// make sure we clean up memory allocated
try
{
- delete ws;
- for (int i = 0; i < input->infos.m_Size; i++)
- delete (BenchBasicDataType *) (input->infos.m_Array[i]);
- delete input;
- if (output)
- {
- for (int i = 0; i < output->infos.m_Size; i++)
- delete (BenchBasicDataType *) (output->infos.m_Array[i]);
- delete output;
- }
+ delete ws;
+ delete input;
+
+ if( output)
+ {
+ delete output;
+ }
}
- catch (AxisException & e)
+ catch( AxisException & e)
{
- cerr << e.what () << endl;
+ cerr << e.what() << endl;
}
- catch (exception & e)
+ catch( exception & e)
{
cout << "Exception : " << e.what () << endl;
}
@@ -335,3 +329,20 @@
}
+static char * asciiToString( char * string)
+{
+ char * pch = string;
+
+ if( string == NULL)
+ {
+ return NULL;
+ }
+
+ /* while not EOL... */
+ while( *pch != '\0')
+ {
+ pch++;
+ }
+
+ return string;
+}
Modified: webservices/axis/trunk/c/samples/client/doclitfault/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/doclitfault/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/doclitfault/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/doclitfault/Client.cpp Fri Apr 28 03:39:58 2006
@@ -42,7 +42,6 @@
const char* p2 = 0;
int i1=0, i2=0;
int iResult;
- char* pcDetail;
// Set default service URL
sprintf (endpoint, "http://localhost:80/axis/doclitfault");
@@ -122,7 +121,7 @@
}
catch(exception& e)
{
- printf("Unknown exception has occured\n");
+ printf("Unknown exception has occured:%s\n", e.what());
}
catch(...)
{
@@ -134,7 +133,7 @@
bool IsNumber(const char* p)
{
- for (int x=0; x < strlen(p); x++)
+ for (int x=0; x < (int) strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
Modified: webservices/axis/trunk/c/samples/client/element/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/element/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/element/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/element/Client.cpp Fri Apr 28 03:39:58 2006
@@ -33,6 +33,7 @@
#ifdef WIN32
// Bug in MS Visual C++ 6.0. Fixed in Visual C++ .Net version.
// Cannot print an __int64 number with cout without this overloading
+/*
std::ostream & operator<< (std::ostream & os, __int64 i)
{
char buf[20];
@@ -40,237 +41,264 @@
os << buf;
return os;
}
+*/
#endif
-static void
-usage (char *programName, char *defaultURL)
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL << endl;
+ cout << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl;
}
-int
-main (int argc, char *argv[])
+int main( int argc, char *argv[])
{
- char endpoint[256];
- const char *url = "http://localhost:80/axis/element";
- char dateTime[50];
+ char endpoint[256];
+ char * url = "http://localhost:80/axis/element";
+ char dateTime[50];
- sprintf (endpoint, "%s", url);
- if (argc > 1)
+ sprintf( endpoint, "%s", url);
+
+ if( argc > 1)
{
- // Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
- {
- usage (argv[0], endpoint);
- return 2;
- }
- sprintf (endpoint, argv[1]);
+// Watch for special case help request
+// Check for - only so that it works for
+//-?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
+ {
+ usage( argv[0], endpoint);
+
+ return 2;
+ }
+
+ sprintf( endpoint, argv[1]);
}
- xsd__boolean boolResult = (xsd__boolean) 1;
- xsd__byte bResult = (xsd__byte) 0;
- xsd__unsignedByte ubResult = (xsd__unsignedByte) 0;
- xsd__short sResult = (xsd__short) 0;
- xsd__unsignedShort usResult = (xsd__unsignedShort) 0;
- xsd__int iResult = (xsd__int) 0;
- xsd__unsignedInt uiResult = (xsd__unsignedInt) 0;
- xsd__long lResult = (xsd__long) 0;
- xsd__unsignedLong ulResult = (xsd__unsignedLong) 0;
- xsd__float fResult = (xsd__float) 0;
- xsd__double dResult = (xsd__double) 0;
- xsd__date dateResult; // typedef of struct tm
- xsd__dateTime dateTimeResult; // typedef of struct tm
- xsd__time timeResult; // typedef of struct tm
- xsd__duration durationResult = (xsd__duration) 0;
- xsd__string strResult = (xsd__string) 0;
- xsd__integer intResult = (xsd__integer) 0;
- xsd__decimal decResult = (xsd__decimal) 0;
- xsd__base64Binary b64Result;
- xsd__hexBinary hexResult;
-
- xsd__base64Binary b64Test;
- xsd__hexBinary hexTest;
-
- //xsd__unsignedByte* testUB = (xsd__unsignedByte*)"never odd or even";
- xsd__unsignedByte *testUB =
- (xsd__unsignedByte *) "<test><xml>some dod&y string</xml></test>";
-
- b64Test.__ptr = testUB;
- b64Test.__size = 41;
- hexTest.__ptr = testUB;
- hexTest.__size = 41;
+ xsd__boolean boolResult = (xsd__boolean) 1;
+ xsd__byte bResult = (xsd__byte) 0;
+ xsd__unsignedByte ubResult = (xsd__unsignedByte) 0;
+ xsd__short sResult = (xsd__short) 0;
+ xsd__unsignedShort usResult = (xsd__unsignedShort) 0;
+ xsd__int iResult = (xsd__int) 0;
+ xsd__unsignedInt uiResult = (xsd__unsignedInt) 0;
+ xsd__long lResult = (xsd__long) 0;
+ xsd__unsignedLong ulResult = (xsd__unsignedLong) 0;
+ xsd__float fResult = (xsd__float) 0;
+ xsd__double dResult = (xsd__double) 0;
+ xsd__date dateResult; // typedef of struct tm
+ xsd__dateTime dateTimeResult; // typedef of struct tm
+// xsd__time timeResult; // typedef of struct tm
+ xsd__duration durationResult = (xsd__duration) 0;
+ xsd__string strResult = (xsd__string) 0;
+ xsd__integer intResult = (xsd__integer) 0;
+ xsd__decimal decResult = (xsd__decimal) 0;
+ xsd__base64Binary b64Result;
+ xsd__hexBinary hexResult;
+ xsd__base64Binary b64Test;
+ xsd__hexBinary hexTest;
+ xsd__unsignedByte * testUB = (xsd__unsignedByte *) "<test><xml>some dod&y string</xml></test>";
+
+ b64Test.set( testUB, (xsd__int) 41);
+ hexTest.set( testUB, (xsd__int) 41);
+
+ time_t timeToTest;
- time_t timeToTest;
timeToTest = 1100246323;
- xsd__date *temp = gmtime (&timeToTest);
- xsd__date testDate;
- memcpy (&testDate, temp, sizeof (xsd__date));
+ xsd__date * temp = gmtime( &timeToTest);
+ xsd__date testDate;
+
+ memcpy( &testDate, temp, sizeof( xsd__date));
- bool bSuccess = false;
- int iRetryIterationCount = 3;
+ bool bSuccess = false;
+ int iRetryIterationCount = 3;
do
{
- try
- {
+ try
+ {
+ XSDElement * ws = new XSDElement( endpoint);
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataBoolean");
+
+ boolResult = ws->setGetDataBoolean( (xsd__boolean) 1);
+
+ cout << "bool=" << boolResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataByte");
+
+ bResult = ws->setGetDataByte( 31);
+
+ cout << "byte=" << bResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataUnsignedByte");
+
+ ubResult = ws->setGetDataUnsignedByte( 32);
+
+ cout << "unsigned byte=" << ubResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataShort");
+
+ sResult = ws->setGetDataShort( 7);
+
+ cout << "short=" << sResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataUnsignedShort");
+
+ usResult = ws->setGetDataUnsignedShort( 14);
+
+ cout << "unsigned short=" << usResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataInt");
+
+ iResult = ws->setGetDataInt( 21);
+
+ cout << "int=" << iResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataUnsignedInt");
+
+ uiResult = ws->setGetDataUnsignedInt( 28);
+
+ cout << "unsigned int=" << uiResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataLong");
+
+ lResult = ws->setGetDataLong( (xsd__long) 35);
+
+ cout << "long=" << lResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataUnsignedLong");
+
+ ulResult = ws->setGetDataUnsignedLong( (xsd__unsignedLong) 42);
+
+ cout << "unsigned long=" << ulResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataFloat");
+
+ fResult = ws->setGetDataFloat( (xsd__float) 35.3535888888);
+
+ cout << "float=" << fResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataDouble");
+
+ dResult = ws->setGetDataDouble( (xsd__double) 70.7175888888);
+
+ printf( "double = %.5f\n", dResult);
+ fflush (stdout);
- XSDElement *ws = new XSDElement (endpoint);
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataDurationType");
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataBoolean");
- boolResult = ws->setGetDataBoolean ((xsd__boolean) 1);
- cout << "bool=" << boolResult << endl;
-
- ws->setTransportProperty ("SOAPAction", "element#setGetDataByte");
- bResult = ws->setGetDataByte (31);
- printf ("byte=%d\n", bResult);
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataUnsignedByte");
- ubResult = ws->setGetDataUnsignedByte (32);
- printf ("unsigned byte=%d\n", ubResult);
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataShort");
- sResult = ws->setGetDataShort (7);
- printf ("short=%d\n", sResult);
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataUnsignedShort");
- usResult = ws->setGetDataUnsignedShort (14);
- printf ("unsigned short=%d\n", usResult);
-
- ws->setTransportProperty ("SOAPAction", "element#setGetDataInt");
- iResult = ws->setGetDataInt (21);
- printf ("int=%d\n", iResult);
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataUnsignedInt");
- uiResult = ws->setGetDataUnsignedInt (28);
- printf ("unsigned int=%d\n", uiResult);
- fflush (stdout);
-
- ws->setTransportProperty ("SOAPAction", "element#setGetDataLong");
- lResult = ws->setGetDataLong ((xsd__long) 35);
- cout << "long=" << lResult << endl;
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataUnsignedLong");
- ulResult = ws->setGetDataUnsignedLong ((xsd__unsignedLong) 42);
- printf ("unsigned long=%d\n", ulResult);
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataFloat");
- fResult = ws->setGetDataFloat ((xsd__float) 35.3535888888);
- printf ("float=%.5f\n", fResult);
- fflush (stdout);
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataDouble");
- dResult = ws->setGetDataDouble ((xsd__double) 70.7175888888);
- printf ("double=%.5f\n", dResult);
- fflush (stdout);
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataDurationType");
- durationResult =
- ws->setGetDataDurationType ((xsd__duration) 123456789);
- cout << "duration=" << durationResult << endl;
-
- ws->setTransportProperty ("SOAPAction", "element#setGetDateType");
- dateResult = ws->setGetDateType (testDate);
- strftime (dateTime, 50, "%a %b %d %Y", &dateResult);
- cout << "date=" << dateTime << endl;
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDateTimeType");
- dateTimeResult = ws->setGetDateTimeType (testDate);
- strftime (dateTime, 50, "%a %b %d %H:%M:%S %Y", &dateTimeResult);
- cout << "dateTime=" << dateTime << endl;
-
-// This is being commented out due to issue on some servers
-// An additional testcase XSDTime has been created to isolate this test.
-// timeResult = ws->setGetTimeType(testDate);
-// strftime(dateTime, 50, "%H:%M:%S", &timeResult);
-// cout << "time=" << dateTime << endl;
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDataString");
- strResult = ws->setGetDataString ("never odd or even");
- cout << "string=" << strResult << endl;
- strResult = ws->setGetDataString ("m");
- cout << "small string=" << strResult << endl;
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetIntegerType");
- intResult = ws->setGetIntegerType (919191919);
- cout << "integer=" << intResult << endl;
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetDecimalType");
- decResult = ws->setGetDecimalType (929292929.5555555555555);
- printf ("decimal=%.5f\n", decResult);
- fflush (stdout);
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetBase64BinaryType");
- b64Result = ws->setGetBase64BinaryType (b64Test);
- cout << "base64Binary size=" << b64Result.__size << endl;
- if (b64Result.__size > 0)
- {
- cout << "base64Binary data=" << b64Result.__ptr << endl;
- }
-
- ws->setTransportProperty ("SOAPAction",
- "element#setGetHexBinary");
- hexResult = ws->setGetHexBinary (hexTest);
- cout << "hexBinary size=" << hexResult.__size << endl;
- if (hexResult.__size > 0)
- {
- cout << "hexBinary data=" << hexResult.__ptr << endl;
- }
-
- bSuccess = true;
- delete ws;
- }
- catch (AxisException & e)
- {
- bool bSilent = false;
-
- if (e.getExceptionCode () ==
- CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
- {
- if (iRetryIterationCount > 0)
+ durationResult = ws->setGetDataDurationType( (xsd__duration) 123456789);
+
+ cout << "duration=" << durationResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDateType");
+
+ dateResult = ws->setGetDateType (testDate);
+
+ strftime( dateTime, 50, "%a %b %d %Y", &dateResult);
+
+ cout << "date=" << dateTime << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDateTimeType");
+
+ dateTimeResult = ws->setGetDateTimeType( testDate);
+
+ strftime( dateTime, 50, "%a %b %d %H:%M:%S %Y", &dateTimeResult);
+
+ cout << "dateTime=" << dateTime << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetDataString");
+
+ strResult = ws->setGetDataString( "never odd or even");
+
+ cout << "string=" << strResult << endl;
+
+ strResult = ws->setGetDataString( "m");
+
+ cout << "small string=" << strResult << endl;
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetIntegerType");
+
+ intResult = ws->setGetIntegerType( 919191919);
+
+ cout << "integer=" << intResult << endl;
+
+ ws->setTransportProperty ("SOAPAction", "element#setGetDecimalType");
+
+ decResult = ws->setGetDecimalType( 929292929.5555555555555);
+
+ printf( "decimal=%.5f\n", decResult);
+ fflush( stdout);
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetBase64BinaryType");
+
+ b64Result = ws->setGetBase64BinaryType( b64Test);
+
+ cout << "base64Binary size=" << b64Result.getSize() << endl;
+
+ if( b64Result.getSize() > 0)
+ {
+ xsd__int iSize;
+
+ cout << "base64Binary data=" << b64Result.get( iSize) << endl;
+ }
+
+ ws->setTransportProperty( "SOAPAction", "element#setGetHexBinary");
+
+ hexResult = ws->setGetHexBinary( hexTest);
+
+ xsd__int iSize = hexResult.getSize();
+
+ cout << "hexBinary size=" << iSize << endl;
+
+ if( iSize > 0)
+ {
+ cout << "hexBinary data=" << hexResult.get( iSize) << endl;
+ }
+
+ bSuccess = true;
+
+ delete ws;
+ }
+ catch( AxisException & e)
{
- bSilent = true;
+ bool bSilent = false;
+
+ if( e.getExceptionCode () == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
+ {
+ if( iRetryIterationCount > 1)
+ {
+ bSilent = true;
+ }
+ }
+ else
+ {
+ iRetryIterationCount = 0;
+ }
+
+ if( !bSilent)
+ {
+ cout << "Exception : " << e.what() << endl;
+ }
}
- }
- else
- {
- iRetryIterationCount = 0;
- }
-
- if (!bSilent)
- {
- cout << "Exception : " << e.what () << endl;
- }
- }
- catch (exception & e)
- {
- cout << "Unknown exception has occured" << endl;
- }
- catch (...)
- {
- cout << "Unknown exception has occured" << endl;
- }
- iRetryIterationCount--;
- }
- while (iRetryIterationCount > 0 && !bSuccess);
- cout <<
- "---------------------- TEST COMPLETE -----------------------------"
- << endl;
- printf ("successful \n");
+ catch( exception & e)
+ {
+ cout << "Unknown exception has occurred" << e.what() << endl;
+ }
+ catch( ...)
+ {
+ cout << "Unknown exception has occurred" << endl;
+ }
+
+ iRetryIterationCount--;
+ } while( iRetryIterationCount > 0 && !bSuccess);
+
+ cout << "---------------------- TEST COMPLETE -----------------------------" << endl;
+
+ cout << "successful" << endl;
+
return 0;
}
Modified: webservices/axis/trunk/c/samples/client/enumeration/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/enumeration/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/enumeration/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/enumeration/Client.cpp Fri Apr 28 03:39:58 2006
@@ -2,131 +2,132 @@
#include "EnumerationWS.hpp"
#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
#include <iostream>
-#include <fstream>
#define WSDL_DEFAULT_ENDPOINT "http://localhost:80/axis/enumeration"
-static void
-usage (char *programName, char *defaultURL)
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL << endl;
+ cout << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl;
}
-// If we re-direct cout it will be to this ofstream
-ofstream output_file;
-int
-main (int argc, char *argv[])
+int main( int argc, char * argv[])
{
- EnumerationWS *ws;
+ EnumerationWS * ws;
- char endpoint[256];
- sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
- int returnValue = 1; // Assume Failure
+ char endpoint[256];
+ int returnValue = 1; // Assume Failure
+ Type1 * input = NULL;
+ Type1 * result = NULL;
+ bool bSuccess = false;
+ int iRetryIterationCount = 3;
- Type1 *input = NULL;
- Type1 *result = NULL;
+ sprintf( endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
- bool bSuccess = false;
- int iRetryIterationCount = 3;
-
- if (argc > 1)
+ if( argc > 1)
{
- // Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
- {
- usage (argv[0], endpoint);
- return 2;
+// Watch for special case help request
+// Check for - only so that it works for
+//-?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
+ {
+ usage( argv[0], endpoint);
+
+ return 2;
+ }
+
+ sprintf( endpoint, argv[1]);
}
- sprintf (endpoint, argv[1]);
- }
do
{
- try
- {
- ws = new EnumerationWS (endpoint, APTHTTP1_1);
-
- input = new Type1 ();
-
- input->enum_string = "one";
- input->att_enum_string = "one";
- input->enum_int = ENUMTYPEINT_0;
- input->att_enum_int = ENUMTYPEINT_1;
- input->att_enum_kind = "CHEQUE";
-
- ws->setTransportProperty ("SOAPAction", "enumeration#getInput");
- result = ws->getInput (input);
-
- cout << "Result" << endl;
- if (result == NULL)
- {
- cout << " result = NULL" << endl;
- }
- else
- {
- cout << "att_enum_int " << result->att_enum_int << endl;
- cout << "att_enum_string " << result->att_enum_string << endl;
- cout << "enum_int " << result->enum_int << endl;
- cout << "enum_string " << result->enum_string << endl;
- cout << "enum_kind " << result->att_enum_kind << endl;
- returnValue = 0; // Success
- }
+ try
+ {
+ ws = new EnumerationWS( endpoint, APTHTTP1_1);
+ input = new Type1();
+
+ xsd__int iEnumInt = ENUMTYPEINT_0;
+
+ input->setatt_enum_string( "one");
+ input->setenum_string( "one");
+ input->setenum_int( &iEnumInt);
+ input->setatt_enum_int( ENUMTYPEINT_1);
+ input->setatt_enum_kind( "CHEQUE");
+
+ ws->setTransportProperty( "SOAPAction", "enumeration#getInput");
+
+ result = ws->getInput( input);
+
+ cout << "Result" << endl;
+
+ if( result == NULL)
+ {
+ cout << " result = NULL" << endl;
+ }
+ else
+ {
+ cout << "att_enum_int " << result->getatt_enum_int() << endl;
+ cout << "att_enum_string " << result->getatt_enum_string() << endl;
+ cout << "enum_int " << result->getenum_int() << endl;
+ cout << "enum_string " << result->getenum_string() << endl;
+ cout << "enum_kind " << result->getatt_enum_kind() << endl;
+
+ returnValue = 0; // Success
+ }
+
+ bSuccess = true;
+ }
+ catch( AxisException & e)
+ {
+ bool bSilent = false;
+
+ if( e.getExceptionCode () == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
+ {
+ if( iRetryIterationCount > 1)
+ {
+ bSilent = true;
+ }
+ }
+ else
+ {
+ iRetryIterationCount = 0;
+ }
+
+ if( !bSilent)
+ {
+ cerr << e.what () << endl;
+ }
+ }
+ catch( ...)
+ {
+ cerr << "Unknown Exception occured." << endl;
+ }
+
+ try
+ {
+ delete ws;
+ delete input;
+ delete result;
+ }
+ catch( exception & exception)
+ {
+ cout << "Exception when cleaning up: " << exception.what() << endl;
+ }
+ catch( ...)
+ {
+ cout << "Unknown exception when cleaning up: " << endl;
+ }
+
+ iRetryIterationCount--;
+ } while( iRetryIterationCount > 0 && !bSuccess);
+
+ cout << "---------------------- TEST COMPLETE -----------------------------" << endl;
+
+ cout << "successful" << endl;
- bSuccess = true;
- }
- catch (AxisException & e)
- {
- bool bSilent = false;
-
- if (e.getExceptionCode () ==
- CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
- {
- if (iRetryIterationCount > 0)
- {
- bSilent = true;
- }
- }
- else
- {
- iRetryIterationCount = 0;
- }
-
- if (!bSilent)
- {
- cerr << e.what () << endl;
- }
- }
- catch (...)
- {
- cerr << "Unknown Exception occured." << endl;
- }
- try
- {
- delete ws;
- delete input;
- delete result;
- }
- catch (exception & exception)
- {
- cout << "Exception when cleaning up: " << exception.
- what () << endl;
- }
- catch (...)
- {
- cout << "Unknown exception when cleaning up: " << endl;
- }
- iRetryIterationCount--;
- }
- while (iRetryIterationCount > 0 && !bSuccess);
- cout <<
- "---------------------- TEST COMPLETE -----------------------------"
- << endl;
- printf ("successful \n");
return returnValue;
}
Modified: webservices/axis/trunk/c/samples/client/groupB/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/groupB/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/groupB/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/groupB/Client.cpp Fri Apr 28 03:39:58 2006
@@ -23,66 +23,75 @@
#define WSDL_DEFAULT_ENDPOINT "http://localhost:80/axis/groupB"
-static void
-usage (char *programName, char *defaultURL)
+static void usage( char * programName, char * defaultURL)
{
- cout << "\nUsage:\n"
- << programName << " [-? | service_url] " << endl
- << " -? Show this help.\n"
- << " service_url URL of the service.\n"
- << " Default service URL is assumed to be " << defaultURL
- <<
- "\n Could use http://localhost:80/axis/groupB"
- << endl;
+ cout << "Usage:" << endl
+ << programName << " [-? | service_url] " << endl
+ << " -? Show this help." << endl
+ << " service_url URL of the service." << endl
+ << " Default service URL is assumed to be " << defaultURL << endl
+ << " Could use http://localhost:80/axis/groupB" << endl;
}
-int main(int argc, char* argv[])
+int main( int argc, char * argv[])
{
- int x;
- char endpoint[256];
+ int x;
+ char endpoint[256];
// Set default service URL
- sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
+ sprintf( endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
+
// Could use http://localhost:8080/axis/services/echo to test with Axis Java
- if (argc > 1)
+ if( argc > 1)
{
- // Watch for special case help request
- if (!strncmp (argv[1], "-", 1)) // Check for - only so that it works for
- //-?, -h or --help; -anything
+// Watch for special case help request
+// Check for - only so that it works for
+// -?, -h or --help; -anything
+ if( !strncmp( argv[1], "-", 1))
{
- usage (argv[0], endpoint);
- return 2;
+ usage( argv[0], endpoint);
+
+ return 2;
}
- sprintf (endpoint, argv[1]);
+
+ sprintf( endpoint, argv[1]);
}
-
cout << endl << " Using service at " << endpoint << endl << endl;
try
{
- InteropTestPortTypeB ws(endpoint);
+ InteropTestPortTypeB ws( endpoint);
/*we do not support multi-dimensional arrays.*/
/*ws.echo2DStringArray*/
/*testing Nested Arrays*/
- SOAPArrayStruct sas;
+ SOAPArrayStruct sas;
+
sas.varFloat = 12345.67890;
sas.varInt = 5000;
- sas.varString = strdup("varString content of SOAPArrayStruct");
+ sas.varString = strdup( "varString content of SOAPArrayStruct");
sas.varArray.m_Array = new AxisChar*[ARRAYSIZE];
sas.varArray.m_Size = ARRAYSIZE;
- for (x=0; x<ARRAYSIZE; x++)
+
+ for( x=0; x < ARRAYSIZE; x++)
+ {
+ sas.varArray.m_Array[x] = strdup( "content of string array element");
+ }
+
+ cout << "invoking echoNestedArray..." << endl;
+
+ ws.setTransportProperty( "SOAPAction" , "groupB#echoNestedArray");
+
+ if( ws.echoNestedArray( &sas) != NULL)
{
- sas.varArray.m_Array[x] = strdup("content of string array element");
+ cout << "successful" << endl;
}
- printf("invoking echoNestedArray...\n");
- ws.setTransportProperty("SOAPAction" , "groupB#echoNestedArray");
- if (ws.echoNestedArray(&sas) != NULL)
- printf("successful\n");
else
- printf("failed\n");
+ {
+ cout << "failed" << endl;
+ }
/*testing Nested Structs*/
SOAPStructStruct sss;
Modified: webservices/axis/trunk/c/samples/client/ref/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/ref/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/ref/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/ref/Client.cpp Fri Apr 28 03:39:58 2006
@@ -21,8 +21,6 @@
int main(int argc, char* argv[])
{
- int x;
- char buffer1[100];
char endpoint[256];
const char* url="http://localhost:80/axis/ref";
sprintf(endpoint, "%s", url);
@@ -91,11 +89,11 @@
}
catch(exception& e)
{
- printf("Unknown exception has occured\n");
+ printf("Unknown exception has occurred: %s\n", e.what());
}
catch(...)
{
- printf("Unknown exception has occured\n");
+ printf("Unknown exception has occurred\n");
}
iRetryIterationCount--;
} while( iRetryIterationCount > 0 && !bSuccess);
Modified: webservices/axis/trunk/c/samples/client/rpcfault/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/rpcfault/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/rpcfault/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/rpcfault/Client.cpp Fri Apr 28 03:39:58 2006
@@ -42,7 +42,6 @@
const char* p2 = 0;
int i1=0, i2=0;
int iResult;
- char* pcDetail;
// Set default service URL
sprintf (endpoint, "http://localhost:80/axis/rpcfault");
@@ -119,11 +118,11 @@
}
catch(exception& e)
{
- printf("Unknown exception has occured\n");
+ printf("Unknown exception has occurred %s\n", e.what());
}
catch(...)
{
- printf("Unknown exception has occured\n");
+ printf("Unknown exception has occurred\n");
}
return 0;
@@ -131,7 +130,7 @@
bool IsNumber(const char* p)
{
- for (int x=0; x < strlen(p); x++)
+ for (int x=0; x < (int) strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
Modified: webservices/axis/trunk/c/samples/client/transportProperties/Client.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/samples/client/transportProperties/Client.cpp?rev=397847&r1=397846&r2=397847&view=diff
==============================================================================
--- webservices/axis/trunk/c/samples/client/transportProperties/Client.cpp (original)
+++ webservices/axis/trunk/c/samples/client/transportProperties/Client.cpp Fri Apr 28 03:39:58 2006
@@ -102,11 +102,11 @@
}
catch (exception & e)
{
- cout << "Unknown exception has occured" << endl;
+ cout << "Unknown exception has occurred " << e.what () << endl;
}
catch (...)
{
- cout << "Unspecified exception has occured" << endl;
+ cout << "Unspecified exception has occurred" << endl;
}
iRetryIterationCount--;
}