axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamej...@apache.org
Subject cvs commit: ws-axis/c/tests/auto_build/testcases/dynamic/DynamicGet_AddAnyObjectTest Calculator.hpp Calculator.cpp
Date Tue, 15 Mar 2005 13:36:45 GMT
jamejose    2005/03/15 05:36:45

  Added:       c/tests/auto_build/testcases/dynamic/DynamicGet_AddAnyObjectTest
                        Calculator.hpp Calculator.cpp
  Log:
  Test for getAnyObject and addAnyObject in Call class - AXISCPP-547
  
  Revision  Changes    Path
  1.1                  ws-axis/c/tests/auto_build/testcases/dynamic/DynamicGet_AddAnyObjectTest/Calculator.hpp
  
  Index: Calculator.hpp
  ===================================================================
  /*
   * This is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
   * to simplify the code to allow the cpp file to be edited to be used as a dynamic client
   */
  #if !defined(__CALCULATOR_CLIENT_H__INCLUDED_)
  #define __CALCULATOR_CLIENT_H__INCLUDED_
  #include <axis/AxisException.hpp>
  #include <axis/client/Call.hpp>
  #include <iostream>
  #include <string>
  #include <exception>
  using namespace std;
  
  AXIS_CPP_NAMESPACE_USE 
  
  class Calculator
  {
  public:
  	STORAGE_CLASS_INFO Calculator(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP1_1);
  	STORAGE_CLASS_INFO Calculator();
  public:
  	STORAGE_CLASS_INFO virtual ~Calculator();
  public: 
  	STORAGE_CLASS_INFO void SetSecure( char *, ...);
  	STORAGE_CLASS_INFO xsd__int div(xsd__int Value0,xsd__int Value1);
  
  private:
  	void includeSecure();
  	Call *m_pCall;
  
  protected:
  	std::string sArguments[8];
  };
  
  #endif /* !defined(__CALCULATOR_CLIENT_H__INCLUDED_)*/
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/dynamic/DynamicGet_AddAnyObjectTest/Calculator.cpp
  
  Index: Calculator.cpp
  ===================================================================
  /*
   * This is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
   * to simplify the code to allow the cpp file to be edited to be used as a dynamic client.
   * This program tests getAnyObject() and addAnyObject() API in Call class
   * @ Author : James Jose
   */
  
  #include "Calculator.hpp"
  #include <axis/AxisWrapperAPI.hpp>
  #include <axis/AxisUserAPI.hpp>
  #include <stdio.h>
  #include <axis/ISoapFault.hpp>
  
  
  
  Calculator::Calculator(const char* pcEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
  {
  	m_pCall=new Call();
  	m_pCall->setProtocol(eProtocol);
  	m_pCall->setEndpointURI(pcEndpointUri);
  	
  }
  
  Calculator::Calculator()
  {
  	m_pCall=new Call();
  	m_pCall->setEndpointURI("http://localhost/axis/Calculator");
  }
  
  Calculator::~Calculator()
  {
  	free(m_pCall);
  	m_pCall=NULL;
  }
  
  
  void Calculator::SetSecure( char * pszArguments, ...)
  {
  	char **	ppszArgPtr = &pszArguments;
  	int		iArgIndex = 0;
  
  	while( *ppszArgPtr != NULL)
  	{
  		sArguments[iArgIndex] = *ppszArgPtr;
  		iArgIndex++;
  		ppszArgPtr++;
  	}
  }
  
  xsd__int Calculator::div(xsd__int Value0, xsd__int Value1)
  {
  	xsd__int Ret = 0;
  	AnyType * any;
  	AnyType* pAny = new AnyType();
      pAny->_size = 2;
      pAny->_array = new char*[2];
  	char *p=new char[100];
  	sprintf(p,"<ns1:arg_0_3>%d</ns1:arg_0_3>",Value0);
  	pAny->_array[0]=strdup(p);
  	sprintf(p,"<ns1:arg_1_3>%d</ns1:arg_1_3>",Value1);
  	//pAny->_array[1]=strdup("<ns1:arg_1_3>0</ns1:arg_1_3>");
  	pAny->_array[1]=strdup(p);
  	const char* pcCmplxFaultName;
  	try
  	{	
  		m_pCall->initialize(CPP_DOC_PROVIDER);
  		m_pCall->setTransportProperty(SOAPACTION_HEADER , "Calculator#div");
  		m_pCall->setSOAPVersion(SOAP_VER_1_1);
  		m_pCall->setOperation("div", "http://localhost/axis/Calculator");
  		includeSecure();
  		char cPrefixAndParamName0[17];	
  		cout<<endl<<m_pCall->addAnyObject(pAny)<<endl;	
  	if (AXIS_SUCCESS == m_pCall->invoke())
  	{
  		if(AXIS_SUCCESS == m_pCall->checkMessage("divResponse", "http://localhost/axis/Calculator"))
  		{
  			any = (AnyType*)m_pCall->getAnyObject();
  			if(any!=NULL){
  				cout << any->_size<<endl;
  				cout << any->_array[0]<<endl;
  			}
  			any = (AnyType*)m_pCall->getAnyObject();
  			any = (AnyType*)m_pCall->getAnyObject();
  			any = (AnyType*)m_pCall->getAnyObject();
  			if(any!=NULL){
  				cout << any->_size<<endl;
  				cout << any->_array[0]<<endl;
  			}			
  		}
  
  	}
  	
  	}
  	catch(AxisException& e)
  	{
  		any = (AnyType*)m_pCall->getAnyObject();
  		if(any!=NULL){
  				cout << any->_size<<endl;
  				cout << any->_array[0]<<endl;
  		}
  		throw;
  	}
  	m_pCall->unInitialize();
  	delete pAny;
  	delete p;
  	return Ret;
  	
  }
  
  
  
  void Calculator::includeSecure()
  {
  	m_pCall->setTransportProperty( SECURE_PROPERTIES, (const char *) &sArguments);
  }
  
  int main(int argc, char* argv[])
  {
  	char endpoint[256];
  	const char* url="http://localhost:9080/Calculator/services/Calculator";
  	int iResult;
  	if(argc > 1){
  		url=argv[1];
  	}
  	try
  	{
  		sprintf(endpoint, "%s", url);
  	    Calculator ws(endpoint);		
  		ws.div(10,2);		
  	}
  	catch(AxisException& e)
  	{
  	    cout << "Exception : " << e.what() << endl;
  	}
  	catch(exception& e)
  	{
  	    cout << "Unknown exception has occured" << endl;
  	}
  	catch(...)
  	{
  		cout << "Unspecified exception has occured" << endl;
  	}
  	cout << "----------------------------TEST COMPLETE------------------------------------"
<< endl;
  	return 0;
  }
  
  
  
  
  
  
  

Mime
View raw message