You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/04/06 13:21:26 UTC

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

samisa      2005/04/06 04:21:26

  Modified:    c/samples/client/base Client.cpp
  Added:       c/samples/client/array Client.cpp
               c/samples/client/calculator Client.cpp
  Log:
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.2       +192 -252  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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Client.cpp	6 Apr 2005 05:25:37 -0000	1.1
  +++ Client.cpp	6 Apr 2005 11:21:26 -0000	1.2
  @@ -1,313 +1,253 @@
  -/*
  - *   Copyright 2003-2004 The Apache Software Foundation.
  - *
  - *   Licensed under the Apache License, Version 2.0 (the "License");
  - *   you may not use this file except in compliance with the License.
  - *   You may obtain a copy of the License at
  - *
  - *       http://www.apache.org/licenses/LICENSE-2.0
  - *
  - *   Unless required by applicable law or agreed to in writing, software
  - *   distributed under the License is distributed on an "AS IS" BASIS,
  - *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - *   See the License for the specific language governing permissions and
  - *   limitations under the License.
  - *
  - *
  - * @author Sanjaya Singharage (sanjayas@opensource.lk)
  - * @author Susantha Kumara (susantha@opensource.lk, skumara@virtusa.com)
  - * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
  - *
  - */
  +// Copyright 2003-2004 The Apache Software Foundation.
  +// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
  +// 
  +// Licensed under the Apache License, Version 2.0 (the "License");
  +// you may not use this file except in compliance with the License.
  +// You may obtain a copy of the License at
  +// 
  +//        http://www.apache.org/licenses/LICENSE-2.0
  +// 
  +// Unless required by applicable law or agreed to in writing, software
  +// distributed under the License is distributed on an "AS IS" BASIS,
  +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +// See the License for the specific language governing permissions and
  +// limitations under the License.
   
  +// InteropBaseClient.cpp : Defines the entry point for the console application.
  +//
   #include <string>
  -#include <iostream>
  -
  -#include <axis/AxisException.hpp>
  -#include "InteropTestPortType.hpp"
  -
   using namespace std;
   
  -#define ARRAYSIZE 2
  -
  -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:8080/axis/services/echo to test with Axis Java."
  -	<< endl;
  -}
  +#include "InteropTestPortType.hpp" 
   
  +#define ARRAYSIZE 2
   
  -int
  -main (int argc, char *argv[])
  +int main(int argc, char* argv[])
   {
  -    int x;
  -    char buffer1[100];
  -    char endpoint[256];
  -
  -    // Set default service URL
  -    sprintf (endpoint, "http://localhost/axis/base");
  -    // Could use http://localhost:8080/axis/services/echo to test with Axis Java
  -
  -    try
  -    {
  -
  +	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)
  -	{
  -	    // 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]);
  -	}
  -
  -
  -	cout << endl << " Using service at " << endpoint << endl << endl;
  -
  +		strcpy(endpoint, argv[1]);
  +	
  +	
  +	bool bSuccess = false;
  +		int	iRetryIterationCount = 3;
  +
  +		do
  +		{
  +	try
  +        {
  +	   InteropTestPortType ws(endpoint, APTHTTP1_1);
   
  -    InteropTestPortType ws (endpoint, APTHTTP1_1);
   
  +	ws.setTransportTimeout(5);
  +	ws.setTransportProperty("SOAPAction" , "InteropBase#echoString");
  +	printf("invoking echoString...\n");
   	//testing echoString 
  -	printf ("invoking echoString...\n");
  -        char* echoStringResult = ws.echoString ("hello world");
  -	if (0 == strcmp (echoStringResult, "hello world"))
  -	    printf ("successful\n");
  -	else
  -	    printf ("failed\n");
  -
  -        // Clean memory 
  -        if (echoStringResult)
  -            delete [] echoStringResult;
  -
  +	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_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;
  -	}
  -	printf ("invoking echoStringArray...\n");
  -	xsd__string_Array arrstrResult = ws.echoStringArray (arrstr);
  -	if (arrstrResult.m_Array != NULL)
  -        {
  -	    printf ("successful\n");
  -            // Do stuff and clean memory
  -            for( int i = 0; i < arrstrResult.m_Size; i++ )
  -                delete[] arrstrResult.m_Array[i];
  -            delete [] arrstrResult.m_Array;
  -        }
  +	sprintf(buffer1, "%dth element of string array", 0);
  +	//sprintf(buffer2, "%dth element of string array", 1);
  +	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");
  -
  -        // Clean memory
  -        delete [] arrstr.m_Array;
  -
  -        ws.setTransportProtocol(APTHTTP1_0);
  +		printf("failed\n");
   	// testing echoInteger 
  -	printf ("invoking echoInteger...\n");
  -	if (ws.echoInteger (56) == 56)
  -	    printf ("successful\n");
  +	ws.setTransportProperty("SOAPAction" , "InteropBase#echoInteger");
  +	printf("invoking echoInteger...\n");
  +	if (ws.echoInteger(56) == 56)
  +		printf("successful\n");
   	else
  -	    printf ("failed\n");
  -
  +		printf("failed\n");
   	// testing echoIntegerArray 
   	xsd__int_Array arrint;
  -	arrint.m_Array = new int[ARRAYSIZE];
  -	arrint.m_Size = ARRAYSIZE;
  -	for (x = 0; x < ARRAYSIZE; x++)
  +	arrint.m_Array = new int*[ARRAYSIZE];
  +    arrint.m_Size = ARRAYSIZE;
  +	int iToSend[ARRAYSIZE];
  +
  +	for (x=0;x<ARRAYSIZE;x++)
   	{
  -	    arrint.m_Array[x] = x;
  +		iToSend[x] = x;
  +		 arrint.m_Array[x] = &iToSend[x];
   	}
  -	printf ("invoking echoIntegerArray...\n");
  -	xsd__int_Array arrintResult = ws.echoIntegerArray (arrint);
  -	if (arrintResult.m_Array != NULL)
  -        {
  -	    printf ("successful\n");
  -            // Do stuff and clean memory
  -            delete [] arrintResult.m_Array;
  -	}
  -        else
  -	    printf ("failed\n");
  -
  -        // Clean memory
  -        delete [] arrint.m_Array;
  -
  +	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");
  +	printf("invoking echoFloat...\n");
   	float fvalue = 1.4214;
  -	if (ws.echoFloat (fvalue) > 1.42)
  -	    printf ("successful\n");
  +	ws.setTransportProperty("SOAPAction" , "InteropBase#echoFloat");
  +	if (ws.echoFloat(fvalue) > 1.42)
  +		printf("successful\n");
   	else
  -	    printf ("failed\n");
  -
  +		printf("failed\n");
   	// testing echoFloat 
   	xsd__float_Array arrfloat;
  -	arrfloat.m_Array = new float[ARRAYSIZE];
  +	 arrfloat.m_Array = new float*[ARRAYSIZE];
   	arrfloat.m_Size = ARRAYSIZE;
  -	for (x = 0; x < ARRAYSIZE; x++)
  +	float fToSend[ARRAYSIZE];
  +	for (x=0;x<ARRAYSIZE;x++)
   	{
  -	    arrfloat.m_Array[x] = 1.1111 * x;
  +		fToSend[x] = 1.1111*x;
  +		arrfloat.m_Array[x] = &fToSend[x];
   	}
  -	printf ("invoking echoFloatArray...\n");
  -        xsd__float_Array arrfloatResult = ws.echoFloatArray (arrfloat);
  -	if (arrfloatResult.m_Array != NULL)
  -        {
  -	    printf ("successful\n");
  -            // Do stuff & clean memory
  -            // It is our responsibility to deallocate deserializer allocated memory
  -            delete [] arrfloatResult.m_Array;
  -        }
  -	else
  -	    printf ("failed\n");
  -        
  -        // Clean memory
  -        delete [] arrfloat.m_Array;
  -
  +	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");
  -	SOAPStruct* stctResult = ws.echoStruct (&stct);
  -	if (stctResult != NULL)
  -        {
  -	    printf ("successful\n");
  -            // Do stuff and clean memory
  -            delete [] stctResult->varString;
  -            delete stctResult;
  -        }
  +	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");
  -
  -        // Clean memory 
  -        free(stct.varString);
  -
  +		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++)
  +	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);
  -	    arrstct.m_Array[x].varString = buffer1;
  -	}
  -
  -	printf ("invoking echoStructArray...\n");
  -        SOAPStruct_Array arrstctResult = ws.echoStructArray (arrstct);
  -	if (arrstctResult.m_Array != NULL)
  -        {
  -	    printf ("successful\n");
  -            // Do stuff and clean memory
  -            for( int i = 0; i < arrstctResult.m_Size; i++ )
  -               delete [] arrstctResult.m_Array[i].varString;
  -            delete [] arrstctResult.m_Array;
  -        }
  +		arrstct.m_Array[x].varFloat = 1.1111*x;
  +		arrstct.m_Array[x].varInt = 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");
  -
  -        // Clean memory
  -        delete [] arrstct.m_Array;
  -
  +		printf("failed\n");
   	//testing echo void
  -	printf ("invoking echoVoid...\n");
  -	ws.echoVoid ();
  -	printf ("successful\n");
  -
  +	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";
  +	const char* bstr = "some string that is sent encoded to either base64Binary or hexBinary";
   
  -	printf ("invoking echoBase64...\n");
  +	printf("invoking echoBase64...\n");
   	xsd__base64Binary bb;
  -	bb.__ptr = (unsigned char *) strdup (bstr);
  -	bb.__size = strlen (bstr);
  -	xsd__base64Binary bbResult = ws.echoBase64 (bb);
  -	if (bb.__size == bbResult.__size)
  +	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");
  -            // Do stuff
  -	    printf ("Returned String :\n%s\n", bbResult.__ptr);
  -            // Clean memory
  -            delete [] bbResult.__ptr;
  +		printf("successful\n");
  +		printf("Returned String :\n%s\n", bb.__ptr);
   	}
   	else
  -	    printf ("failed\n");
  -
  -        // Clean memory
  -        free(bb.__ptr);
  +		printf("failed\n");
   
   	time_t tim;
  -	time (&tim);
  -	tm *lt = gmtime (&tim);
  -	printf ("invoking echoDate...\n");
  -	if (memcmp (&ws.echoDate (*lt), lt, sizeof (tm)) == 0)
  -	    printf ("successful\n");
  +	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");
  -
  +		printf("failed\n");
   	//testing echo hex binary
   
  -	printf ("invoking echoHexBinary...\n");
  +	printf("invoking echoHexBinary...\n");
   	xsd__hexBinary hb;
  -	hb.__ptr = (unsigned char *) strdup (bstr);
  -	hb.__size = strlen (bstr);
  -	xsd__hexBinary hbResult = ws.echoHexBinary (hb);
  -	if (hb.__size == hbResult.__size)
  +	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");
  -            // Do stuff
  -	    printf ("Returned String :\n%s\n", hbResult.__ptr);
  -            // Clean memory
  -            delete [] hbResult.__ptr;
  +		printf("successful\n");
  +		printf("Returned String :\n%s\n", hb.__ptr);
   	}
   	else
  -	    printf ("failed\n");
  -
  -        // Clean memory
  -        free(hb.__ptr);
  -
  +		printf("failed\n");
   	//testing echo decimal
  -	printf ("invoking echoDecimal...\n");
  -	if (ws.echoDecimal (1234.567890) > 1234.56)
  -	    printf ("successful\n");
  +	printf("invoking echoDecimal...\n");
  +	ws.setTransportProperty("SOAPAction" , "InteropBase#echoDecimal");
  +	if (ws.echoDecimal(1234.567890) > 1234.56)
  +		printf("successful\n");
   	else
  -	    printf ("failed\n");
  -
  +		printf("failed\n");
   	//testing echo boolean
  -	printf ("invoking echoBoolean...\n");
  -	if (ws.echoBoolean (true_) == true_)
  -	    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;
  +	printf("invoking echoBoolean...\n");
  +	ws.setTransportProperty("SOAPAction" , "InteropBase#echoBoolean");
  +	if (ws.echoBoolean(true_) == true_)
  +		printf("successful\n");
  +	else
  +		printf("failed\n");
  +
  +	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)
  +			{
  +		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);
  +	//getchar();
  +	return 0;
   }
  
  
  
  1.1                  ws-axis/c/samples/client/array/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  // Copyright 2003-2004 The Apache Software Foundation.
  // 
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  // 
  //        http://www.apache.org/licenses/LICENSE-2.0
  // 
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  // ArrayClient.cpp : Defines the entry point for the console application.i
  //
  #include <string>
  using namespace std;
  
  #include "ArrayTestPortType.hpp"
  #include <axis/AxisException.hpp>
  #include <iostream>
  
  #define ARRAYSIZE 2
  
  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:8080/axis/services/echo to test with Axis Java."
  	<< endl;
  }
  
  int main(int argc, char* argv[])
  {
  	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
          {
  	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]);
  	}
  
  
  	cout << endl << " Using service at " << endpoint << endl << endl;
  
  	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");		
  	}
          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.1                  ws-axis/c/samples/client/calculator/Client.cpp
  
  Index: Client.cpp
  ===================================================================
  // Copyright 2003-2004 The Apache Software Foundation.
  // 
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  // 
  //        http://www.apache.org/licenses/LICENSE-2.0
  // 
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  #include "Calculator.hpp"
  #include <axis/AxisException.hpp>
  #include <iostream>
  
  bool IsNumber(const char* p);
  
  static void
  usage (char *programName, char *defaultURL)
  {
      cout << "\nUsage:\n"
  	<< 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;
  }
  
  int main(int argc, char* argv[])
  {
  	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;
      int iResult;
  
      // Set default service URL
      sprintf (endpoint, "http://localhost/axis/Calculator");
      sprintf(original, "http://localhost/axis/Calculator");
  
  	try
      {
      if( argc ==1 )
      {
          usage(argv[0], endpoint);
          return 2;
      }
  
      if (argc > 1)
      {
          if(!strncmp (argv[1], "-", 1))
  	    {
              // Check for - only so that it works for 
              //-?, -h or --help; -anything 
  
              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]);      
          }
      }
  
  	cout << endl << " Using service at " << endpoint << endl << endl;
  	Calculator ws(endpoint);
  
  	op = argv[1];
  	p1 = argv[2];
  	p2 = argv[3];
  
  	if (!IsNumber(p1))
  	{
  		printf("Invalid value for first <parameter>\n\n");
  		usage(original, argv[4]);
          return 2;
  	}
  	if (!IsNumber(p2))
  	{
  		printf("Invalid value for second <parameter>\n\n");
  		usage(original, argv[4]);
          return 2;
  	}
  	
  	i1 = atoi(p1);
  	i2 = atoi(p2);
  
  	if (strcmp(op, "add") == 0)
  	{
                  iResult = ws.add(i1, i2);
                  printf("%d\n", iResult);
  	}
  	else 	if (strcmp(op, "sub") == 0)
  	{
  		iResult = ws.sub(i1, i2);
          printf("%d\n", iResult);
  	}
  	else 	if (strcmp(op, "mul") == 0)
  	{
  	        iResult = ws.mul(i1, i2);
              printf("%d\n", iResult);
  	}
  	else 	if (strcmp(op, "div") == 0)
  	{
  		iResult = ws.div(i1, i2);
          printf("%d\n", iResult);
  	}
  	else 
  	{
  		printf("Invalid operation %s\n\n", op);
  		usage(original, argv[4]);
          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;
  }
  
  bool IsNumber(const char* p)
  {
  	for (int x=0; x < strlen(p); x++)
  	{
  		if (!isdigit(p[x])) return false;
  	}
  	return true;
  }