axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanj...@apache.org
Subject cvs commit: ws-axis/c/samples/client/doclitfault MathOpsClient.cpp
Date Thu, 21 Oct 2004 05:04:43 GMT
sanjaya     2004/10/20 22:04:43

  Modified:    c/samples/client/doclitfault MathOpsClient.cpp
  Log:
  argument format of client changed
  
  Revision  Changes    Path
  1.6       +63 -27    ws-axis/c/samples/client/doclitfault/MathOpsClient.cpp
  
  Index: MathOpsClient.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/doclitfault/MathOpsClient.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MathOpsClient.cpp	6 Jul 2004 08:34:41 -0000	1.5
  +++ MathOpsClient.cpp	21 Oct 2004 05:04:43 -0000	1.6
  @@ -1,49 +1,89 @@
   #include "MathOps.h"
   #include <axis/server/AxisException.h>
   #include <ctype.h>
  +#include <iostream>
   
   void PrintUsage();
   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];
  -	const char* server="localhost";
  -	const char* port="80";
  +    char original[256];
   	const char* op = 0;
   	const char* p1 = 0;
   	const char* p2 = 0;
   	int i1=0, i2=0;
  -        int iResult;
  -        char* pcDetail;
  -        try
  +    int iResult;
  +    char* pcDetail;
  +
  +    // Set default service URL
  +    sprintf (endpoint, "http://localhost/axis/MathOpsDL");
  +    sprintf(original, "http://localhost/axis/MathOpsDL");
  +
  +    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)
           {
  -	if (argc < 6)
  -	{
  -		PrintUsage();
  -	}
  -	else
  -	{
  -		server = argv[1];
  -		port = argv[2];
  -	}
  -	printf("Sending Requests to Server http://%s:%s ........\n\n", server, port);
  -	sprintf(endpoint, "http://%s:%s/axis/MathOpsDL", server, port);
  +            sprintf(endpoint, argv[4]);      
  +        }
  +    }
  +
  +	cout << endl << " Using service at " << endpoint << endl <<
endl;
  +
   	MathOps ws(endpoint);
   
  -	op = argv[3];
  -	p1 = argv[4];
  -	p2 = argv[5];
  +	op = argv[1];
  +	p1 = argv[2];
  +	p2 = argv[3];
   
   	if (!IsNumber(p1))
   	{
   		printf("Invalid value for first <parameter>\n\n");
  -		PrintUsage();
  +		usage(argv[0], original);
  +        return 2;
   	}
   	if (!IsNumber(p2))
   	{
   		printf("Invalid value for second <parameter>\n\n");
  -		PrintUsage();
  +		usage(argv[0], original);
  +        return 2;
   	}
   	
   	i1 = atoi(p1);
  @@ -57,7 +97,8 @@
   	else 
   	{
   		printf("Invalid operation %s\n\n", op);
  -		PrintUsage();
  +		usage(argv[0], original);
  +        return 2;
   	}
           }
           catch(AxisException& e)
  @@ -75,11 +116,6 @@
   	return 0;
   }
   
  -void PrintUsage()
  -{
  -	printf("Usage :\n doclitmathops <server> <port> <operation> <parameter>
<parameter>\n\n");
  -	exit(1);
  -}
   
   bool IsNumber(const char* p)
   {
  
  
  

Mime
View raw message