axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject cvs commit: ws-axis/c/samples/client/ssl_client CalcClient.cpp Calculator.cpp Calculator.h Makefile.am
Date Thu, 25 Nov 2004 12:34:46 GMT
damitha     2004/11/25 04:34:46

  Modified:    c/samples/client/ssl_client Makefile.am
  Added:       c/samples/client/ssl_client CalcClient.cpp Calculator.cpp
                        Calculator.h
  Log:
  ssl client files added. This is just a normal client. but in future this
  will be helpful for investigating more into ssl
  
  Revision  Changes    Path
  1.8       +3 -6      ws-axis/c/samples/client/ssl_client/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/ssl_client/Makefile.am,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Makefile.am	7 Apr 2004 08:47:22 -0000	1.7
  +++ Makefile.am	25 Nov 2004 12:34:46 -0000	1.8
  @@ -1,8 +1,5 @@
   bin_PROGRAMS = sslclient
  -SUBDIRS =
  -AM_CFLAGS = $(CFLAGS)
  -#sslclient_SOURCES = InteropBaseClient.c InteropTestPortType.c  SOAPStruct.c
  -sslclient_SOURCES = InteropBaseClient.c InteropTestPortType.c
  -
  -sslclient_LDADD   =  $(LDFLAGS) -lssl
  +AM_CPPFLAGS = $(CPPFLAGS)
  +sslclient_SOURCES = Calculator.cpp CalcClient.cpp
  +sslclient_LDADD   =  @LINKCLIENTLIB@
   INCLUDES = -I$(AXISCPP_HOME)/include
  
  
  
  1.1                  ws-axis/c/samples/client/ssl_client/CalcClient.cpp
  
  Index: CalcClient.cpp
  ===================================================================
  #include "Calculator.h"
  #include <axis/AxisGenException.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;
      char* pcDetail;
      pcDetail = 0;
  
      // Set default service URL
      sprintf (endpoint, "https://localhost:443/axis/Calculator");
      sprintf(original, "https://localhost:443/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);
                  ws.getFaultDetail(&pcDetail);
                  printf("%d\n", iResult);
                  /*printf("pcDetail:%s\n", pcDetail);*/
  	}
  	else 	if (strcmp(op, "sub") == 0)
  	{
  		iResult = ws.sub(i1, i2);
          printf("%d\n", iResult);
  		ws.getFaultDetail(&pcDetail);
          /*printf("pcDetail:%s\n", pcDetail);*/
  	}
  	else 	if (strcmp(op, "mul") == 0)
  	{
  	        iResult = ws.mul(i1, i2);
              printf("%d\n", iResult);
  			ws.getFaultDetail(&pcDetail);
              /*printf("pcDetail:%s\n", pcDetail);*/
  	}
  	else 	if (strcmp(op, "div") == 0)
  	{
  		iResult = ws.div(i1, i2);
          printf("%d\n", iResult);
  		ws.getFaultDetail(&pcDetail);
          /*printf("pcDetail:%s\n", pcDetail);*/
  	}
  	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;
  }
  
  
  
  1.1                  ws-axis/c/samples/client/ssl_client/Calculator.cpp
  
  Index: Calculator.cpp
  ===================================================================
  /*
   * This is the Client Stub implementation file genarated by WSDL2Ws tool.
   * Calculator.cpp: implemtation for the Calculator.
   *
   */
  
  #include "Calculator.h"
  
  #include <axis/AxisWrapperAPI.hpp>
  
  AXIS_CPP_NAMESPACE_USE
  
  bool CallBase::bInitialized;
  //CallFunctions CallBase::ms_VFtable;
  Calculator::Calculator(const char* pchEndpointUri)
  {
  	m_pCall = new Call();
  	m_pCall->setProtocol(APTHTTP1_1);
  	m_pCall->setEndpointURI(pchEndpointUri);
  }
  
  Calculator::~Calculator()
  {
  	delete m_pCall;
  }
  
  
  /*Methods corresponding to the web service methods*/
  
  /*
   * This method wrap the service methodadd
   */
  int Calculator::add(int Value0, int Value1)
  {
  	int Ret;
  	if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
  	m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#add");
  	m_pCall->setSOAPVersion(SOAP_VER_1_1);
  	m_pCall->setOperation("add", "http://localhost/axis/Calculator");
  	m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
  	m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
  	if (AXIS_SUCCESS == m_pCall->invoke())
  	{
  		if(AXIS_SUCCESS == m_pCall->checkMessage("addResponse", "http://localhost/axis/Calculator"))
  		{
  			Ret = m_pCall->getElementAsInt("addReturn", 0);
                          printf("Ret:%d\n", Ret);
  		}
  	}
  	m_pCall->unInitialize();
  	return Ret;
  }
  
  
  /*
   * This method wrap the service methodsub
   */
  int Calculator::sub(int Value0, int Value1)
  {
  	int Ret;
  	if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
  	m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#sub");
  	m_pCall->setSOAPVersion(SOAP_VER_1_1);
  	m_pCall->setOperation("sub", "http://localhost/axis/Calculator");
  	m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
  	m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
  	if (AXIS_SUCCESS == m_pCall->invoke())
  	{
  		if(AXIS_SUCCESS == m_pCall->checkMessage("subResponse", "http://localhost/axis/Calculator"))
  		{
  			Ret = m_pCall->getElementAsInt("subReturn", 0);
  			printf("Ret:%d\n", Ret);
  		}
  	}
  	m_pCall->unInitialize();
  	return Ret;
  }
  
  
  /*
   * This method wrap the service methodmul
   */
  int Calculator::mul(int Value0, int Value1)
  {
  	int Ret;
  	if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
  	m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#mul");
  	m_pCall->setSOAPVersion(SOAP_VER_1_1);
  	m_pCall->setOperation("mul", "http://localhost/axis/Calculator");
  	m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
  	m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
  	if (AXIS_SUCCESS == m_pCall->invoke())
  	{
  		if(AXIS_SUCCESS == m_pCall->checkMessage("mulResponse", "http://localhost/axis/Calculator"))
  		{
  			Ret = m_pCall->getElementAsInt("addReturn", 0);
  			printf("Ret:%d\n", Ret);
  		}
  	}
  	m_pCall->unInitialize();
  	return Ret;
  }
  
  
  /*
   * This method wrap the service methoddiv
   */
  int Calculator::div(int Value0, int Value1)
  {
  	int Ret;
  	if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
  	m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#div");
  	m_pCall->setSOAPVersion(SOAP_VER_1_1);
  	m_pCall->setOperation("div", "http://localhost/axis/Calculator");
  	m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
  	m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
  	if (AXIS_SUCCESS == m_pCall->invoke())
  	{
  		if(AXIS_SUCCESS == m_pCall->checkMessage("divResponse", "http://localhost/axis/Calculator"))
  		{
  			Ret = m_pCall->getElementAsInt("addReturn", 0);
  			printf("Ret:%d\n", Ret);
  		}
  	}
  	m_pCall->unInitialize();
  	return Ret;
  }
  
  int Calculator::getFaultDetail(char** ppcDetail)
  {
      m_pCall->getFaultDetail(ppcDetail);
  	return 0;
  }
  
  
  
  
  1.1                  ws-axis/c/samples/client/ssl_client/Calculator.h
  
  Index: Calculator.h
  ===================================================================
  /*
   * This is the Client Stub Class genarated by the tool WSDL2Ws
   * Calculator.h: interface for the Calculatorclass.
   *
   */
  #if !defined(__CALCULATOR_CLIENTSTUB_H__OF_AXIS_INCLUDED_)
  #define __CALCULATOR_CLIENTSTUB_H__OF_AXIS_INCLUDED_
  
  #include <axis/client/Stub.hpp>
  #include <axis/client/Call.hpp>
  #include <ctype.h>
  
  AXIS_CPP_NAMESPACE_USE
  
  class Calculator 
  {
  private:
  	Call* m_pCall;
  public:
  	Calculator(const char* pchEndpointUri);
  public:
  	virtual ~Calculator();
  public: 
  	int add(int Value0,int Value1);
  	int sub(int Value0,int Value1);
  	int mul(int Value0,int Value1);
  	int div(int Value0,int Value1);
          int getFaultDetail(char** ppcDetail);
  };
  
  #endif /* !defined(__CALCULATOR_CLIENTSTUB_H__OF_AXIS_INCLUDED_)*/
  
  
  

Mime
View raw message