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 sa...@apache.org on 2005/04/07 05:51:37 UTC

cvs commit: ws-axis/c/samples/client/transportProperties Client.cpp

samisa      2005/04/06 20:51:37

  Modified:    c/samples/client/array Client.cpp
               c/samples/client/base Client.cpp
               c/samples/client/bench Client.cpp
               c/samples/client/calculator Client.cpp
               c/samples/client/element Client.cpp
               c/samples/client/enumeration Client.cpp
               c/samples/client/transportProperties Client.cpp
  Log:
  Improvements to sample main programs to help change URL etc.
  
  Revision  Changes    Path
  1.2       +43 -39    ws-axis/c/samples/client/array/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/array/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 11:21:26 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:36 -0000	1.2
  @@ -30,29 +30,26 @@
   	<< 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:8080/axis/services/echo to test with Axis Java."
  -	<< endl;
  +	<< "    Default service URL is assumed to be " << defaultURL << endl;
   }
   
  -int main(int argc, char* argv[])
  +int
  +main (int argc, char *argv[])
   {
  -	int x;
  -	char buffer1[100];
  -	char endpoint[256];
  +    int x;
  +    char buffer1[100];
  +    char endpoint[256];
   
       // Set default service URL
       sprintf (endpoint, "http://localhost/axis/array");
  -    // Could use http://localhost:8080/axis/services/echo to test with Axis Java
   
  -	try
  -        {
  +    try
  +    {
   	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 
  +	    if (!strncmp (argv[1], "-", 1))	// Check for - only so that it works for 
  +		//-?, -h or --help; -anything 
   	    {
   		usage (argv[0], endpoint);
   		return 2;
  @@ -63,32 +60,39 @@
   
   	cout << endl << " Using service at " << endpoint << endl << endl;
   
  -	ArrayTestPortType ws(endpoint);
  +	ArrayTestPortType ws (endpoint);
   	//testing echoIntArray
  -         intArrayType arrin;
  -         arrin.intItem.m_Array = new int*[ARRAYSIZE];
  -         arrin.intItem.m_Size = ARRAYSIZE;
  -         for (x=0;x<ARRAYSIZE;x++)
  -         {
  -           arrin.intItem.m_Array[x] = &x;
  -         }
  -         printf("invoking echoIntArray...\n");
  -         if (ws.echoIntArray(&arrin)->intItem.m_Array != NULL)
  -	          printf("successful \n");
  -      else
  -	          printf("failed \n");		
  +	intArrayType arrin;
  +	arrin.intItem.m_Array = new int *[ARRAYSIZE];
  +	arrin.intItem.m_Size = ARRAYSIZE;
  +	for (x = 0; x < ARRAYSIZE; x++)
  +	{
  +	    arrin.intItem.m_Array[x] = &x;
   	}
  -        catch(AxisException& e)
  -        {
  -            printf("Exception : %s\n", e.what());
  -        }
  -        catch(exception& e)
  -        {
  -            printf("Unknown exception has occured\n");
  -        }
  -        catch(...)
  -        {
  -            printf("Unknown exception has occured\n");
  -        }
  -	return 0;
  +	printf ("invoking echoIntArray...\n");
  +
  +	intArrayType *arrout = ws.echoIntArray (&arrin);
  +
  +	for (int i = 0; i < arrout->intItem.m_Size; i++)
  +	    cout << "Element " << i + 1 
  +                 << " of returned arrya is " << *(arrout->intItem.m_Array[i]) << endl;
  +
  +	if (arrout->intItem.m_Array != NULL)
  +	    printf ("successful \n");
  +	else
  +	    printf ("failed \n");
  +    }
  +    catch (AxisException & e)
  +    {
  +	printf ("Exception : %s\n", e.what ());
  +    }
  +    catch (exception & e)
  +    {
  +	printf ("Unknown exception has occured\n");
  +    }
  +    catch (...)
  +    {
  +	printf ("Unknown exception has occured\n");
  +    }
  +    return 0;
   }
  
  
  
  1.3       +246 -207  ws-axis/c/samples/client/base/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/base/Client.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Client.cpp	6 Apr 2005 11:21:26 -0000	1.2
  +++ Client.cpp	7 Apr 2005 03:51:36 -0000	1.3
  @@ -16,238 +16,277 @@
   // InteropBaseClient.cpp : Defines the entry point for the console application.
   //
   #include <string>
  +#include <iostream>
   using namespace std;
   
  -#include "InteropTestPortType.hpp" 
  +#include "InteropTestPortType.hpp"
   
   #define ARRAYSIZE 2
   
  -int main(int argc, char* argv[])
  +static void
  +usage (char *programName, char *defaultURL)
   {
  -	int x;
  -	char buffer1[100];
  -	char endpoint[256];
  -	const char* server="localhost";
  -	const char* port="80";
  -	sprintf(endpoint, "http://%s:%s/axis/InteropBase", server, port);
  -		
  -	if (argc > 1)
  -		strcpy(endpoint, argv[1]);
  -	
  -	
  -	bool bSuccess = false;
  -		int	iRetryIterationCount = 3;
  -
  -		do
  -		{
  -	try
  -        {
  -	   InteropTestPortType ws(endpoint, APTHTTP1_1);
  +    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;
  +}
   
   
  -	ws.setTransportTimeout(5);
  -	ws.setTransportProperty("SOAPAction" , "InteropBase#echoString");
  -	printf("invoking echoString...\n");
  -	//testing echoString 
  -	string bigstring;
  -	for (int ii=0;ii<2;ii++)
  +int
  +main (int argc, char *argv[])
  +{
  +    int x;
  +    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)
  +    {
  +	// Watch for special case help request
  +	if (!strncmp (argv[1], "-", 1))	// Check for - only so that it works for
  +	    //-?, -h or --help; -anything
   	{
  -		bigstring += "hello world ";
  +	    usage (argv[0], endpoint);
  +	    return 2;
   	}
  -	strcpy(buffer1, bigstring.c_str());
  -	ws.setTransportProperty("SOAPAction" , "InteropBase#echoString");
  -	printf(ws.echoString(buffer1));
  -	if (0 == strcmp(ws.echoString("hello world"), "hello world"))
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	// testing echoStringArray 
  -	xsd__string_Array arrstr;
  -	arrstr.m_Array = new char*[ARRAYSIZE];
  -	arrstr.m_Size = ARRAYSIZE;
  -	sprintf(buffer1, "%dth element of string array", 0);
  -	//sprintf(buffer2, "%dth element of string array", 1);
  -	for(int i=0; i< ARRAYSIZE; i++)
  +	sprintf (endpoint, argv[1]);
  +    }
  +
  +    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");
  +	    printf (ws.echoString (buffer1));
  +	    if (0 == strcmp (ws.echoString ("hello world"), "hello world"))
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +	    
  +            // 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 (int i = 0; i < ARRAYSIZE; i++)
  +	    {
   		arrstr.m_Array[i] = buffer1;
  -	}
  -	//arrstr.m_Array[1] = buffer2;
  -	ws.setTransportProperty("SOAPAction" , "InteropBase#echoStringArray");
  -	printf("invoking echoStringArray...\n");
  -	if (ws.echoStringArray(arrstr).m_Array != NULL)
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	// 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++)
  -	{
  +	    ws.setTransportProperty ("SOAPAction",
  +				     "InteropBase#echoStringArray");
  +	    printf ("invoking echoStringArray...\n");
  +	    if (ws.echoStringArray (arrstr).m_Array != NULL)
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +
  +	    // 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");
  -	if (ws.echoIntegerArray(arrint).m_Array != NULL)
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	// 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;
  +		arrint.m_Array[x] = &iToSend[x];
  +	    }
  +	    ws.setTransportProperty ("SOAPAction",
  +				     "InteropBase#echoIntegerArray");
  +	    printf ("invoking echoIntegerArray...\n");
  +	    if (ws.echoIntegerArray (arrint).m_Array != NULL)
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +
  +	    // 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");
  -	if (ws.echoFloatArray(arrfloat).m_Array != NULL)
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	// testing echo Struct
  -	SOAPStruct stct;
  -	stct.varFloat = 12345.7346345;
  -	stct.varInt = 5000;
  -	stct.varString = strdup("This is string in SOAPStruct");
  -	printf("invoking echoStruct...\n");
  -	ws.setTransportProperty("SOAPAction" , "InteropBase#echoStruct");
  -	if (ws.echoStruct(&stct) != NULL)
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	//testing echo Array of Struct
  -	SOAPStruct_Array arrstct;
  -	arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
  -	arrstct.m_Size = ARRAYSIZE;
  -	for (x=0;x<ARRAYSIZE;x++)
  -	{
  -		arrstct.m_Array[x].varFloat = 1.1111*x;
  +	    }
  +	    ws.setTransportProperty ("SOAPAction",
  +				     "InteropBase#echoFloatArray");
  +	    printf ("invoking echoFloatArray...\n");
  +	    if (ws.echoFloatArray (arrfloat).m_Array != NULL)
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +
  +	    // testing echo Struct
  +	    SOAPStruct stct;
  +	    stct.varFloat = 12345.7346345;
  +	    stct.varInt = 5000;
  +	    stct.varString = strdup ("This is string in SOAPStruct");
  +	    printf ("invoking echoStruct...\n");
  +	    ws.setTransportProperty ("SOAPAction", "InteropBase#echoStruct");
  +	    if (ws.echoStruct (&stct) != NULL)
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +
  +	    //testing echo Array of Struct
  +	    SOAPStruct_Array arrstct;
  +	    arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
  +	    arrstct.m_Size = ARRAYSIZE;
  +	    for (x = 0; x < ARRAYSIZE; x++)
  +	    {
  +		arrstct.m_Array[x].varFloat = 1.1111 * x;
   		arrstct.m_Array[x].varInt = x;
  -		sprintf(buffer1, "varString of %dth element of SOAPStruct array", x);
  +		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");
  -	if (ws.echoStructArray(arrstct).m_Array != NULL)
  -		printf("successful\n");
  -	else
  -		printf("failed\n");
  -	//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");
  -	if (bb.__size == ws.echoBase64(bb).__size)
  -	{
  -		printf("successful\n");
  -		printf("Returned String :\n%s\n", bb.__ptr);
  -	}
  -	else
  -		printf("failed\n");
  +	    }
   
  -	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");
  -	if (hb.__size == ws.echoHexBinary(hb).__size)
  -	{
  -		printf("successful\n");
  -		printf("Returned String :\n%s\n", hb.__ptr);
  -	}
  -	else
  -		printf("failed\n");
  -	//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");
  +	    //testing echo Struct Array
  +	    ws.setTransportProperty ("SOAPAction",
  +				     "InteropBase#echoStructArray");
  +	    printf ("invoking echoStructArray...\n");
  +	    if (ws.echoStructArray (arrstct).m_Array != NULL)
  +		printf ("successful\n");
  +	    else
  +		printf ("failed\n");
  +
  +	    //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");
  +	    if (bb.__size == ws.echoBase64 (bb).__size)
  +	    {
  +		printf ("successful\n");
  +		printf ("Returned String :\n%s\n", bb.__ptr);
  +	    }
  +	    else
  +		printf ("failed\n");
  +
  +	    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");
  +	    if (hb.__size == ws.echoHexBinary (hb).__size)
  +	    {
  +		printf ("successful\n");
  +		printf ("Returned String :\n%s\n", hb.__ptr);
  +	    }
  +	    else
  +		printf ("failed\n");
  +
  +	    //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");
   
  -	bSuccess = true;
  +	    bSuccess = true;
   	}
  -	catch(AxisException& e)
  +	catch (AxisException & e)
   	{
  -			bool bSilent = false;
  +	    bool bSilent = false;
   
  -			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  -			{
  -				if( iRetryIterationCount > 0)
  -				{
  -					bSilent = true;
  -				}
  -			}
  -			else
  -			{
  -				iRetryIterationCount = 0;
  -			}
  -
  -            if( !bSilent)
  -			{
  -		printf("%s\n", e.what());
  -			}
  +	    if (e.getExceptionCode () ==
  +		CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  +	    {
  +		if (iRetryIterationCount > 0)
  +		{
  +		    bSilent = true;
  +		}
  +	    }
  +	    else
  +	    {
  +		iRetryIterationCount = 0;
  +	    }
  +
  +	    if (!bSilent)
  +	    {
  +		printf ("%s\n", e.what ());
  +	    }
   	}
  -	catch(exception& e)
  +	catch (exception & e)
   	{
  -		printf("%s\n", e.what());
  +	    printf ("%s\n", e.what ());
   	}
  -	catch(...)
  +	catch (...)
   	{
  -		printf("Unknown exception has occured\n");
  +	    printf ("Unknown exception has occured\n");
   	}
  -		iRetryIterationCount--;
  -		} while( iRetryIterationCount > 0 && !bSuccess);
  -	//getchar();
  -	return 0;
  +	iRetryIterationCount--;
  +    }
  +    while (iRetryIterationCount > 0 && !bSuccess);
  +    //getchar();
  +    return 0;
   }
  
  
  
  1.2       +265 -303  ws-axis/c/samples/client/bench/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/bench/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 13:42:28 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:37 -0000	1.2
  @@ -4,372 +4,334 @@
   #include <time.h>
   
   #ifndef WIN32
  -  #include "sys/time.h"
  +#include "sys/time.h"
   #else
  -  #include "sys/timeb.h"
  +#include "sys/timeb.h"
   
     // 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 );
  +    sprintf (buf, "%I64d", i);
       os << buf;
       return os;
  -  }
  +}
   
   #endif
   
   static bool verbose = false;
  -#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
  -
  -// Prototype
  -bool parse_args_for_endpoint(int *argc, char *argv[], char **endpoint);
  -void shift_args(int i, int *argc, char *argv[]);
  -void setLogOptions(const char *output_filename);
  +#include <stdlib.h>		// For malloc(), calloc(), strdup() and free()
   
   // If we re-direct cout it will be to this ofstream
   ofstream output_file;
   
   #define WSDL_DEFAULT_ENDPOINT "http://localhost:80/axis/bench"
   
  -int main(int argc, char* argv[])
  -{ 
  -  AxisBench *ws;
  +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;
  +}
   
  -  BenchDataType *input = NULL;
  -  BenchDataType *output = NULL;
  -  xsd__unsignedByte* buffer = NULL;
  +int
  +main (int argc, char *argv[])
  +{
  +    AxisBench *ws;
  +
  +    BenchDataType *input = NULL;
  +    BenchDataType *output = NULL;
  +    xsd__unsignedByte *buffer = NULL;
  +
  +    char endpoint[256];
  +    sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
  +    int returnValue = 1;	// Assume Failure
  +
  +
  +    bool bSuccess = false;
  +    int iRetryIterationCount = 3;
  +    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);
   
  -  char *endpoint = WSDL_DEFAULT_ENDPOINT;
  -  bool endpoint_set = false;
  -  int returnValue = 1; // Assume Failure
   
  -  endpoint_set = parse_args_for_endpoint(&argc, argv, &endpoint);
  +	    int request = 1;
   
  -		bool bSuccess = false;
  -		int	iRetryIterationCount = 3;
  +	    input = new BenchDataType ();
  +	    input->count = 10;
   
  -		do
  -		{
  -  try {
  -    if(endpoint_set) {
  -      ws = new AxisBench("http://localhost:80/axis/bench", APTHTTP1_1);
  -      free(endpoint);
  -      endpoint_set = false;
  -    } else
  -      ws = new AxisBench("http://localhost:80/axis/bench");
  -//	ws.setTransportProperty("SOAPAction" , "AxisBench#doBenchRequest");
  -
  -    
  -    int request = 1;
  -      
  -    input = new BenchDataType();
  -    input->count = 10;
  -      
  -//    input->infos.m_Array = new BenchBasicDataType[input->count];
  -	BenchBasicDataType **	ppBBDT = (BenchBasicDataType **) new BenchBasicDataType *[input->count];
  +	    BenchBasicDataType **ppBBDT =
  +		(BenchBasicDataType **) new BenchBasicDataType*[input->count];
   
   #ifdef WIN32
  -	__int64					ll = 10000;
  +	    __int64 ll = 10000;
   #else
  -	long long				ll = 10000;
  +	    long long ll = 10000;
   #endif
   
  -	input->infos.m_Array = ppBBDT;
  +	    input->infos.m_Array = ppBBDT;
   
  -    input->infos.m_Size = input->count;
  -      
  -    time_t tim;
  -    tim = 1100246323;
  -    struct tm *temp = gmtime(&tim);
  -    struct tm lt;
  -    memcpy(&lt, temp, sizeof(struct tm));
  -
  -      
  -    buffer = (xsd__unsignedByte*)calloc (1, input->count + 2);
  -    strcpy ( (char *)buffer, "A");
  -
  -    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;
  +	    input->infos.m_Size = input->count;
   
  -		if( i == 90)
  +	    time_t tim;
  +	    tim = 1100246323;
  +	    struct tm *temp = gmtime (&tim);
  +	    struct tm lt;
  +	    memcpy (&lt, temp, sizeof (struct tm));
  +
  +
  +	    buffer = (xsd__unsignedByte *) calloc (1, input->count + 2);
  +	    strcpy ((char *) buffer, "A");
  +
  +	    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;
  +
  +		if (i == 90)
   		{
  -			*ppBBDT = type;
  -//			*ppBBDT = NULL;
  +		    *ppBBDT = type;
   		}
   		else
   		{
  -			*ppBBDT = type;
  +		    *ppBBDT = type;
   		}
   
   		ppBBDT++;
   
  -		if( ll == 0)
  +		if (ll == 0)
   		{
  -			ll = 1;
  +		    ll = 1;
   		}
   		else
   		{
  -			ll += 10000;
  +		    ll += 10000;
   		}
   
  -        strcat ( (char *)buffer, "A");
  -    }
  +		strcat ((char *) buffer, "A");
  +	    }
   
  -    int t1,t2;
  -#ifndef WIN32  
  -    struct timeval mstart;
  -    struct timeval mstop;
  -    gettimeofday( &mstart, NULL );
  +	    int t1, t2;
  +#ifndef WIN32
  +	    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);
  -    }
  +	    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);
  +	    }
   
  -    free(buffer);
  +	    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;
  -      
  -    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;
  +	    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)
  -			  {
  -				  cout << " Base64BinaryType " << output->infos.m_Array[i]->Base64BinaryType.__ptr << endl;
  -			  }
  -
  -			  cout << " HexBinaryType " << output->infos.m_Array[i]->HexBinary.__size << endl;
  -			  if( output->infos.m_Array[i]->HexBinary.__size > 0)
  -			  {
  -				cout << " HexBinaryType " << output->infos.m_Array[i]->HexBinary.__ptr << endl;
  -			  }
  -		  }
  -		  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( iRetryIterationCount > 0)
  -				{
  -					bSilent = true;
  -				}
  -			}
  -			else
  +//                        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)
   			{
  -				iRetryIterationCount = 0;
  +			    cout << " Base64BinaryType " << output->infos.
  +				m_Array[i]->Base64BinaryType.__ptr << endl;
   			}
   
  -            if( !bSilent)
  +			cout << " HexBinaryType " << output->infos.
  +			    m_Array[i]->HexBinary.__size << endl;
  +			if (output->infos.m_Array[i]->HexBinary.__size > 0)
   			{
  -				cout << "Exception : " << e.what() << endl;
  +			    cout << " HexBinaryType " << output->infos.
  +				m_Array[i]->HexBinary.__ptr << endl;
   			}
  -  } catch(...) {
  -    cerr << "Unknown Exception occured." << endl;
  -  }
  -
  -  // Samisa: 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;
  -	  }
  -  }
  -  catch(AxisException& e)
  -  {
  -    cerr << e.what() << endl;
  -  }
  -  catch(exception& e)
  -  {
  -				cout << "Exception : " << e.what() << endl;
  -  }
  -  catch(...)
  -  {
  -  	cout << "Unknown exception on clean up: " << endl;
  -  }
  -		iRetryIterationCount--;
  -		} while( iRetryIterationCount > 0 && !bSuccess);
  -    if(endpoint_set)
  -      free(endpoint);
  -		cout << "---------------------- TEST COMPLETE -----------------------------"<< endl;
  -		printf("successful \n");
  -  return returnValue;
  -
  -}
  -
  -/* Spin through args list and check for -e -p and -s options.
  -   Option values are expected to follow the option letter as the next
  -   argument.
  - 
  -   These options and values are removed from the arg list.
  -   If both -e and -s and or -p, then -e takes priority
  -*/
  -bool parse_args_for_endpoint(int *argc, char *argv[], char **endpoint) {
  -
  -    // We need at least 2 extra arg after program name
  -    if(*argc < 3)
  -        return false;
  -
  -    char *server = "localhost";
  -    int  port = 80;
  -    bool ep_set = false;
  -    bool server_set = false;
  -    bool port_set = false;
  -
  -    for(int i=1; i<*argc; i++) {
  -        if(*argv[i] == '-') {
  -            switch(*(argv[i]+1)) {
  -            case 'e':
  -                *endpoint = strdup(argv[i+1]);
  -                ep_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 's':
  -                server = strdup(argv[i+1]);
  -                server_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 'p':
  -                port = atoi(argv[i+1]);
  -                if(port >80) port_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 'o':
  -                setLogOptions(argv[i+1]);
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 'v':
  -				verbose=true;
  -                break;
  -            default:
  -                break;
  -            }
  -        }
  -    }
  +		    }
  +		    returnValue = 0;
  +		}
  +	    }
   
  -    // use the supplied server and/or port to build the endpoint
  -    if(ep_set == false && (server_set || port_set)) {
  -        // Set p to the location of the first '/' after the http:// (7 chars)
  -        // e.g. from http://localhost:80/axis/base gets /axis/base
  -        char *ep_context = strpbrk(&(*endpoint)[7], "/");
  -
  -        // http://:/ is 9 characters + terminating NULL character so add 10.
  -        // Allow space for port number upto 999999 6 chars
  -        *endpoint = (char *)calloc(1, 10 + strlen(ep_context) + strlen(server) + 6);
  -        sprintf(*endpoint, "http://%s:%d/%s", server, port, ep_context+1);
  -        if(server_set) free(server);
  -        ep_set = true;
  +	    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 (iRetryIterationCount > 0)
  +		{
  +		    bSilent = true;
  +		}
  +	    }
  +	    else
  +	    {
  +		iRetryIterationCount = 0;
  +	    }
  +
  +	    if (!bSilent)
  +	    {
  +		cout << "Exception : " << e.what () << endl;
  +	    }
  +	}
  +	catch (...)
  +	{
  +	    cerr << "Unknown Exception occured." << endl;
  +	}
  +
  +	// 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;
  +	    }
  +	}
  +	catch (AxisException & e)
  +	{
  +	    cerr << e.what () << endl;
  +	}
  +	catch (exception & e)
  +	{
  +	    cout << "Exception : " << e.what () << endl;
  +	}
  +	catch (...)
  +	{
  +	    cout << "Unknown exception on clean up: " << endl;
  +	}
  +	iRetryIterationCount--;
       }
  +    while (iRetryIterationCount > 0 && !bSuccess);
  +    cout <<
  +	"---------------------- TEST COMPLETE -----------------------------"
  +	<< endl;
  +    printf ("successful \n");
  +    return returnValue;
   
  -    return ep_set;
  -}
  -
  -void shift_args(int i, int *argc, char *argv[]) {
  -    for(int j=i, k=i+2; j<*(argc)-2; j++, k++)
  -        argv[j]=argv[k];
  -    *argc-=2;
  -}
  -
  -void setLogOptions(const char *output_filename) {
  -    output_file.open(output_filename, ios::out);
  -    if(output_file.is_open()) {
  -        cout.rdbuf( output_file.rdbuf() );
  -    }
   }
   
  
  
  
  1.2       +87 -87    ws-axis/c/samples/client/calculator/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/calculator/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 11:21:26 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:37 -0000	1.2
  @@ -16,7 +16,7 @@
   #include <axis/AxisException.hpp>
   #include <iostream>
   
  -bool IsNumber(const char* p);
  +bool IsNumber (const char *p);
   
   static void
   usage (char *programName, char *defaultURL)
  @@ -25,128 +25,128 @@
   	<< programName << " [-? | div number1 number2 [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:8080/axis/services/echo to test with Axis Java."
  -	<< 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];
  +    char endpoint[256];
       char original[256];
  -	const char* server="localhost";
  -	const char* port="80";
  -	const char* op = 0;
  -	const char* p1 = 0;
  -	const char* p2 = 0;
  -	int i1=0, i2=0;
  +    const char *server = "localhost";
  +    const char *port = "80";
  +    const char *op = 0;
  +    const char *p1 = 0;
  +    const char *p2 = 0;
  +    int i1 = 0, i2 = 0;
       int iResult;
   
       // Set default service URL
  -    sprintf (endpoint, "http://localhost/axis/Calculator");
  -    sprintf(original, "http://localhost/axis/Calculator");
  +    sprintf (endpoint, "http://localhost/axis/calculator");
  +    sprintf (original, endpoint);
   
  -	try
  +    try
       {
  -    if( argc ==1 )
  -    {
  -        usage(argv[0], endpoint);
  -        return 2;
  -    }
  +	if (argc == 1)
  +	{
  +	    usage (argv[0], endpoint);
  +	    return 2;
  +	}
   
  -    if (argc > 1)
  -    {
  -        if(!strncmp (argv[1], "-", 1))
  +	if (argc > 1)
  +	{
  +	    if (!strncmp (argv[1], "-", 1))
   	    {
  -            // Check for - only so that it works for 
  -            //-?, -h or --help; -anything 
  +		// Check for - only so that it works for 
  +		//-?, -h or --help; -anything 
   
  -            usage(argv[0], endpoint);
  -            return 2;
  +		usage (argv[0], endpoint);
  +		return 2;
   	    }
  -        //less than minimum number of args OR greater than maximum number of args
  -       	else if (argc < 4 || argc > 5)
  -    	{
  -		    usage(argv[0], endpoint);
  -            return 2;
  -    	}
  -        else if (argc == 5)
  -        {
  -            sprintf(endpoint, argv[4]);      
  -        }
  -    }
  +	    //less than minimum number of args OR greater than maximum number of args
  +	    else if (argc < 4 || argc > 5)
  +	    {
  +		usage (argv[0], endpoint);
  +		return 2;
  +	    }
  +	    else if (argc == 5)
  +	    {
  +		sprintf (endpoint, argv[4]);
  +	    }
  +	}
   
   	cout << endl << " Using service at " << endpoint << endl << endl;
  -	Calculator ws(endpoint);
  +	Calculator ws (endpoint);
   
   	op = argv[1];
   	p1 = argv[2];
   	p2 = argv[3];
   
  -	if (!IsNumber(p1))
  +	if (!IsNumber (p1))
   	{
  -		printf("Invalid value for first <parameter>\n\n");
  -		usage(original, argv[4]);
  -        return 2;
  +	    printf ("Invalid value for first <parameter> %s\n\n", p1);
  +	    usage (argv[0], original);
  +	    return 2;
   	}
  -	if (!IsNumber(p2))
  +	if (!IsNumber (p2))
   	{
  -		printf("Invalid value for second <parameter>\n\n");
  -		usage(original, argv[4]);
  -        return 2;
  +	    printf ("Invalid value for second <parameter> %s\n\n", p2);
  +	    usage (argv[0], original);
  +	    return 2;
   	}
  -	
  -	i1 = atoi(p1);
  -	i2 = atoi(p2);
   
  -	if (strcmp(op, "add") == 0)
  +	i1 = atoi (p1);
  +	i2 = atoi (p2);
  +
  +	if (strcmp (op, "add") == 0)
   	{
  -                iResult = ws.add(i1, i2);
  -                printf("%d\n", iResult);
  +	    iResult = ws.add (i1, i2);
  +	    printf ("%d\n", iResult);
   	}
  -	else 	if (strcmp(op, "sub") == 0)
  +	else if (strcmp (op, "sub") == 0)
   	{
  -		iResult = ws.sub(i1, i2);
  -        printf("%d\n", iResult);
  +	    iResult = ws.sub (i1, i2);
  +	    printf ("%d\n", iResult);
   	}
  -	else 	if (strcmp(op, "mul") == 0)
  +	else if (strcmp (op, "mul") == 0)
   	{
  -	        iResult = ws.mul(i1, i2);
  -            printf("%d\n", iResult);
  +	    iResult = ws.mul (i1, i2);
  +	    printf ("%d\n", iResult);
   	}
  -	else 	if (strcmp(op, "div") == 0)
  +	else if (strcmp (op, "div") == 0)
   	{
  -		iResult = ws.div(i1, i2);
  -        printf("%d\n", iResult);
  +	    iResult = ws.div (i1, i2);
  +	    printf ("%d\n", iResult);
   	}
  -	else 
  +	else
   	{
  -		printf("Invalid operation %s\n\n", op);
  -		usage(original, argv[4]);
  -        return 2;
  +	    printf ("Invalid operation %s\n\n", op);
  +	    usage (argv[0], original);
  +	    return 2;
   	}
  -        }
  -        catch(AxisException& e)
  -        {
  -            printf("Exception : %s\n", e.what());
  -        }
  -        catch(exception& e)
  -        {
  -            printf("Unknown exception has occured\n" );
  -        }
  -	catch(...)
  -        {
  -            printf("Unknown exception has occured\n" );
  -        }
  -	return 0;
  +    }
  +    catch (AxisException & e)
  +    {
  +	printf ("Exception : %s\n", e.what ());
  +    }
  +    catch (exception & e)
  +    {
  +	printf ("Unknown exception has occured\n");
  +    }
  +    catch (...)
  +    {
  +	printf ("Unknown exception has occured\n");
  +    }
  +    return 0;
   }
   
  -bool IsNumber(const char* p)
  +bool
  +IsNumber (const char *p)
   {
  -	for (int x=0; x < strlen(p); x++)
  -	{
  -		if (!isdigit(p[x])) return false;
  -	}
  -	return true;
  +    for (int x = 0; x < strlen (p); x++)
  +    {
  +	if (!isdigit (p[x]))
  +	    return false;
  +    }
  +    return true;
   }
  
  
  
  1.2       +209 -164  ws-axis/c/samples/client/element/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/element/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 13:42:28 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:37 -0000	1.2
  @@ -33,199 +33,244 @@
   #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 )
  -  {
  +std::ostream & operator<< (std::ostream & os, __int64 i)
  +{
       char buf[20];
  -    sprintf(buf,"%I64d", i );
  +    sprintf (buf, "%I64d", i);
       os << buf;
       return os;
  -  }
  +}
   #endif
   
  -int main(int argc, char* argv[])
  +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;
  +}
  +
  +int
  +main (int argc, char *argv[])
   {
  -	char endpoint[256];
  -	const char* url="http://localhost:80/axis/element";
  -	char dateTime[50];
  -
  -	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;
  +    char endpoint[256];
  +    const char *url = "http://localhost:80/axis/element";
  +    char dateTime[50];
  +
  +    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]);
  +    }
  +
  +    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;
   
       time_t timeToTest;
       timeToTest = 1100246323;
  -    xsd__date *temp = gmtime(&timeToTest);
  +    xsd__date *temp = gmtime (&timeToTest);
       xsd__date testDate;
  -    memcpy(&testDate, temp, sizeof(xsd__date));
  +    memcpy (&testDate, temp, sizeof (xsd__date));
   
  -	if(argc>1)
  -		url = argv[1];
   
  -		bool bSuccess = false;
  -		int	iRetryIterationCount = 3;
  +    bool bSuccess = false;
  +    int iRetryIterationCount = 3;
   
  -		do
  -		{
  +    do
  +    {
   	try
   	{
  -		
  -		sprintf(endpoint, "%s", url);
  -		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);
  -		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);
  +	    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);
  +	    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;
  +	    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;
  -		}
  +//              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;
  +	    }
   
  -		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;
  +	    bSuccess = true;
  +	    delete ws;
   	}
  -	catch(AxisException& e)
  +	catch (AxisException & e)
   	{
  -			bool bSilent = false;
  +	    bool bSilent = false;
   
  -			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  -			{
  -				if( iRetryIterationCount > 0)
  -				{
  -					bSilent = true;
  -				}
  -			}
  -			else
  -			{
  -				iRetryIterationCount = 0;
  -			}
  -
  -            if( !bSilent)
  -			{
  -				cout << "Exception : " << e.what() << endl;
  -			}
  +	    if (e.getExceptionCode () ==
  +		CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  +	    {
  +		if (iRetryIterationCount > 0)
  +		{
  +		    bSilent = true;
  +		}
  +	    }
  +	    else
  +	    {
  +		iRetryIterationCount = 0;
  +	    }
  +
  +	    if (!bSilent)
  +	    {
  +		cout << "Exception : " << e.what () << endl;
  +	    }
   	}
  -	catch(exception& e)
  +	catch (exception & e)
   	{
   	    cout << "Unknown exception has occured" << endl;
   	}
  -	catch(...)
  +	catch (...)
   	{
   	    cout << "Unknown exception has occured" << endl;
   	}
  -		iRetryIterationCount--;
  -		} while( iRetryIterationCount > 0 && !bSuccess);
  -	cout<< "---------------------- TEST COMPLETE -----------------------------"<< endl;
  -	printf("successful \n");
  -	return 0;
  +	iRetryIterationCount--;
  +    }
  +    while (iRetryIterationCount > 0 && !bSuccess);
  +    cout <<
  +	"---------------------- TEST COMPLETE -----------------------------"
  +	<< endl;
  +    printf ("successful \n");
  +    return 0;
   }
  -
  
  
  
  1.2       +116 -175  ws-axis/c/samples/client/enumeration/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/enumeration/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 13:42:28 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:37 -0000	1.2
  @@ -1,191 +1,132 @@
   
  -#include "EnumerationWS.hpp" 
  -#include <stdlib.h> // For malloc(), calloc(), strdup() and free()
  +#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"
   
  -// Prototype
  -bool parse_args_for_endpoint(int *argc, char *argv[], char **endpoint);
  -void shift_args(int i, int *argc, char *argv[]);
  -void setLogOptions(const char *output_filename);
  +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;
  +}
   
   // 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;
  -
  -  char *endpoint = WSDL_DEFAULT_ENDPOINT;
  -  bool endpoint_set = false;
  -  int returnValue = 1; // Assume Failure
  -
  -  Type1* input = NULL;
  -  Type1* result = NULL;
  -
  -  endpoint_set = parse_args_for_endpoint(&argc, argv, &endpoint);
  -
  -		bool bSuccess = false;
  -		int	iRetryIterationCount = 3;
  -
  -		do
  -		{
  -  try {
  -    if(endpoint_set) {
  -      ws = new EnumerationWS("http://localhost:80/axis/enumeration", APTHTTP1_1);
  -      free(endpoint);
  -      endpoint_set = false;
  -    } else
  -      ws = new EnumerationWS("http://localhost:80/axis/enumeration");
  -
  -    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
  -    }
  +    EnumerationWS *ws;
   
  -	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);
  -    if(endpoint_set)
  -      free(endpoint);
  -  cout << "---------------------- TEST COMPLETE -----------------------------"<< endl;
  -  printf("successful \n");
  -  return returnValue;
  -}
  -
  -/* Spin through args list and check for -e -p and -s options.
  -   Option values are expected to follow the option letter as the next
  -   argument.
  - 
  -   These options and values are removed from the arg list.
  -   If both -e and -s and or -p, then -e takes priority
  -*/
  -bool parse_args_for_endpoint(int *argc, char *argv[], char **endpoint) {
  -
  -    // We need at least 2 extra arg after program name
  -    if(*argc < 3)
  -        return false;
  -
  -    char *server = "localhost";
  -    int  port = 80;
  -    bool ep_set = false;
  -    bool server_set = false;
  -    bool port_set = false;
  -
  -    for(int i=1; i<*argc; i++) {
  -        if(*argv[i] == '-') {
  -            switch(*(argv[i]+1)) {
  -            case 'e':
  -                *endpoint = strdup(argv[i+1]);
  -                ep_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 's':
  -                server = strdup(argv[i+1]);
  -                server_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 'p':
  -                port = atoi(argv[i+1]);
  -                if(port >80) port_set = true;
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            case 'o':
  -                setLogOptions(argv[i+1]);
  -                shift_args(i, argc, argv);
  -                i--;
  -                break;
  -            default:
  -                break;
  -            }
  -        }
  +    char endpoint[256];
  +    sprintf (endpoint, "%s", WSDL_DEFAULT_ENDPOINT);
  +    int returnValue = 1;	// Assume Failure
  +
  +    Type1 *input = NULL;
  +    Type1 *result = NULL;
  +
  +    bool bSuccess = false;
  +    int iRetryIterationCount = 3;
  +
  +    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]);
       }
   
  -    // use the supplied server and/or port to build the endpoint
  -    if(ep_set == false && (server_set || port_set)) {
  -        // Set p to the location of the first '/' after the http:// (7 chars)
  -        // e.g. from http://localhost:80/axis/base gets /axis/base
  -        char *ep_context = strpbrk(&(*endpoint)[7], "/");
  -
  -        // http://:/ is 9 characters + terminating NULL character so add 10.
  -        // Allow space for port number upto 999999 6 chars
  -        *endpoint = (char *)calloc(1, 10 + strlen(ep_context) + strlen(server) + 6);
  -        sprintf(*endpoint, "http://%s:%d/%s", server, port, ep_context+1);
  -        if(server_set) free(server);
  -        ep_set = true;
  -    }
  -
  -    return ep_set;
  -}
  -
  -void shift_args(int i, int *argc, char *argv[]) {
  -    for(int j=i, k=i+2; j<*(argc)-2; j++, k++)
  -        argv[j]=argv[k];
  -    *argc-=2;
  -}
  -void setLogOptions(const char *output_filename) {
  -    output_file.open(output_filename, ios::out);
  -    if(output_file.is_open()){
  -        cout.rdbuf( output_file.rdbuf() );
  +    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
  +	    }
  +
  +	    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;
   }
  -
  
  
  
  1.2       +110 -82   ws-axis/c/samples/client/transportProperties/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/transportProperties/Client.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 13:42:28 -0000	1.1
  +++ Client.cpp	7 Apr 2005 03:51:37 -0000	1.2
  @@ -7,102 +7,130 @@
   #include <stdio.h>
   #include <iostream>
   
  -void printProperties(Calculator *obj);
  -
  -int main(int argc, char* argv[])
  +static void
  +usage (char *programName, char *defaultURL)
   {
  -	char endpoint[256];
  -	const char* url="http://localhost:80/axis/transportProperties";
  -	int iResult;
  -	int rc=1;
  +    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;
  +}
   
  -	url = argv[1];
  +void printProperties (Calculator * obj);
   
  -		bool bSuccess = false;
  -		int	iRetryIterationCount = 3;
  +int
  +main (int argc, char *argv[])
  +{
  +    char endpoint[256];
  +    const char *url = "http://localhost:80/axis/transportProperties";
  +    int iResult;
  +    int rc = 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]);
  +    }
   
  -		do
  -		{
  +    bool bSuccess = false;
  +    int iRetryIterationCount = 3;
  +
  +    do
  +    {
   	try
   	{
  -		sprintf(endpoint, "%s", url);
  -		Calculator ws("http://localhost:80/axis/transportProperties");
  -		ws.setTransportProperty("SOAPAction" , "transportProperties#add");
  -		ws.setTransportProtocol(APTHTTP1_1);
  -		ws.setTransportProperty("Accept-Language", " da, en-gb;q=0.8, en;q=0.7");
  -		ws.setTransportProperty("Accept-Language", "l1");
  -		ws.setTransportProperty("Date", "Mon Dec  6 13:37:06 GMT 2004");
  -		ws.setTransportProperty("Accept-Language", "l22");
  -		
  -		cout << "Full properties list " << endl;
  -		printProperties(&ws);
  -
  -		//deleting the transport with specific key value
  -		ws.deleteTransportProperty("Accept-Language",2);
  -
  -		cout << "After deleteTransportProperty(key,int) method  " << endl;
  -		printProperties(&ws);
  -
  -		//Go to the last property and delete
  -		ws.getFirstTransportPropertyKey();
  -		ws.getNextTransportPropertyKey();
  -		ws.getNextTransportPropertyKey();
  -		ws.deleteCurrentTransportProperty();
  -		cout << "After deleteCurrentProperty method " << endl;
  -		printProperties(&ws);
  -		
  -		iResult = ws.add(2,3);
  -		cout << iResult << endl;
  -		rc=0;
  -		bSuccess = true;
  +	    Calculator ws (endpoint);
  +	    ws.setTransportProperty ("SOAPAction", "transportProperties#add");
  +	    ws.setTransportProtocol (APTHTTP1_1);
  +	    ws.setTransportProperty ("Accept-Language",
  +				     " da, en-gb;q=0.8, en;q=0.7");
  +	    ws.setTransportProperty ("Accept-Language", "l1");
  +	    ws.setTransportProperty ("Date", "Mon Dec  6 13:37:06 GMT 2004");
  +	    ws.setTransportProperty ("Accept-Language", "l22");
  +
  +	    cout << "Full properties list " << endl;
  +	    printProperties (&ws);
  +
  +	    //deleting the transport with specific key value
  +	    ws.deleteTransportProperty ("Accept-Language", 2);
  +
  +	    cout << "After deleteTransportProperty(key,int) method  " << endl;
  +	    printProperties (&ws);
  +
  +	    //Go to the last property and delete
  +	    ws.getFirstTransportPropertyKey ();
  +	    ws.getNextTransportPropertyKey ();
  +	    ws.getNextTransportPropertyKey ();
  +	    ws.deleteCurrentTransportProperty ();
  +	    cout << "After deleteCurrentProperty method " << endl;
  +	    printProperties (&ws);
  +
  +	    iResult = ws.add (2, 3);
  +	    cout << iResult << endl;
  +	    rc = 0;
  +	    bSuccess = true;
   	}
  -	catch(AxisException& e)
  +	catch (AxisException & e)
   	{
  -			bool bSilent = false;
  +	    bool bSilent = false;
   
  -			if( e.getExceptionCode() == CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  -			{
  -				if( iRetryIterationCount > 0)
  -				{
  -					bSilent = true;
  -				}
  -			}
  -			else
  -			{
  -				iRetryIterationCount = 0;
  -			}
  -
  -            if( !bSilent)
  -			{
  -				cout << "Exception : " << e.what() << endl;
  -			}
  +	    if (e.getExceptionCode () ==
  +		CLIENT_TRANSPORT_OPEN_CONNECTION_FAILED)
  +	    {
  +		if (iRetryIterationCount > 0)
  +		{
  +		    bSilent = true;
  +		}
  +	    }
  +	    else
  +	    {
  +		iRetryIterationCount = 0;
  +	    }
  +
  +	    if (!bSilent)
  +	    {
  +		cout << "Exception : " << e.what () << endl;
  +	    }
   	}
  -	catch(exception& e)
  +	catch (exception & e)
   	{
  -		cout << "Unknown exception has occured" << endl;
  +	    cout << "Unknown exception has occured" << endl;
   	}
  -	catch(...)
  +	catch (...)
   	{
  -		cout << "Unspecified exception has occured" << endl;
  +	    cout << "Unspecified exception has occured" << endl;
   	}
  -		iRetryIterationCount--;
  -		} while( iRetryIterationCount > 0 && !bSuccess);
  -  cout << "---------------------- TEST COMPLETE -----------------------------"<< endl;
  -  printf("successful \n");
  -	return rc;
  +	iRetryIterationCount--;
  +    }
  +    while (iRetryIterationCount > 0 && !bSuccess);
  +    cout <<
  +	"---------------------- TEST COMPLETE -----------------------------"
  +	<< endl;
  +    printf ("successful \n");
  +    return rc;
   }
  -void printProperties(Calculator *obj)
  +
  +void
  +printProperties (Calculator * obj)
   {
  -	const char* transprop1;
  -	transprop1 = obj->getFirstTransportPropertyKey();
  -	do
  -	{
  -		transprop1 = obj->getCurrentTransportPropertyKey();
  -		cout << "current transport property key = " << transprop1 ;
  -		transprop1 = obj->getCurrentTransportPropertyValue();
  -		cout << " value = " << transprop1 << endl;
  -	}
  -	while ( (transprop1 = obj->getNextTransportPropertyKey()) != NULL);
  -	cout << "****************************************************** " << endl;
  -	return ;	
  +    const char *transprop1;
  +    transprop1 = obj->getFirstTransportPropertyKey ();
  +    do
  +    {
  +	transprop1 = obj->getCurrentTransportPropertyKey ();
  +	cout << "current transport property key = " << transprop1;
  +	transprop1 = obj->getCurrentTransportPropertyValue ();
  +	cout << " value = " << transprop1 << endl;
  +    }
  +    while ((transprop1 = obj->getNextTransportPropertyKey ()) != NULL);
  +    cout << "****************************************************** " << endl;
  +    return;
   }