axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ros...@apache.org
Subject cvs commit: ws-axis/c/src/client/deployment AdminClient.cpp
Date Wed, 22 Oct 2003 11:29:13 GMT
roshan      2003/10/22 04:29:13

  Modified:    c/src/client/deployment AdminClient.cpp
  Log:
  code improvement
  
  Revision  Changes    Path
  1.6       +178 -64   ws-axis/c/src/client/deployment/AdminClient.cpp
  
  Index: AdminClient.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/client/deployment/AdminClient.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AdminClient.cpp	20 Oct 2003 06:42:08 -0000	1.5
  +++ AdminClient.cpp	22 Oct 2003 11:29:13 -0000	1.6
  @@ -63,8 +63,11 @@
   
   #include <axis/client/Call.h>
   #include <axis/wsdd/WSDDDeployment.h>
  +#include "AdminClientHelper.h"
   
   int processDeployWSDD(char* pchWSDDPath);
  +int processUnDeployWSDD(char* pchWSDDPath);
  +void printMessage();
   
   const AxisChar* pAchServiceName;
   const AxisChar* pAchLibName;
  @@ -72,63 +75,125 @@
   //string* sArrAllowedMethods;
   string sArrAllowedMethods[10];
   int iAllowdMethodsArraySize=0;
  +char* pchMethodName = "";
  +ADMIN_CLIENT_METHOD eADMIN_CLIENT_METHOD;
  +char* pchMessage = "";
   
   int main(int argc, char *argv[ ]) {
   
  +	if (argc < 3) {
  +		printf("Problem occured.\nUsage: %s <Method_Name> <WSDD_FilePath>", argv[0]);

  +		exit(1);
  +	}
  +
  +	pchMethodName = argv[1];
  +
  +	if (strcmp(pchMethodName, "deploy") == 0) {
  +		eADMIN_CLIENT_METHOD = AC_DEPLOY;
  +	} else if (strcmp(pchMethodName, "undeploy") == 0) {
  +		eADMIN_CLIENT_METHOD = AC_UNDEPLOY;
  +	} else {
  +		eADMIN_CLIENT_METHOD = AC_UNKNOWN;
  +	}
  +
  +	if (eADMIN_CLIENT_METHOD == AC_UNKNOWN) {
  +		printf("Problem occured.\nMethod_Name should be deploy OR undeploy");
  +		exit(1);
  +	}
  +
   	int nStatus;
   	int ret = 0;
  -	char* chWSDDPath = "E:/axiscppdev/ws-axis/c/release/win32/deploy.wsdd";	
  +	char* chWSDDPath = "";	
   
   	Call* m_pCall;
   	m_pCall = new Call();
   
   	/*
  -	 *Process the client side deployment WSDD and extract the required details
  +	 *Process the client side deploy or undeploy WSDD and extract the required details
   	 */
  -	processDeployWSDD(chWSDDPath);
   
  -	/* The protocol can be taken from the binding section in the WSDL */
  -	m_pCall->SetProtocol(APTHTTP);
  -	/* The value for SOAPAction is specified in the binding section of the WSDL */
  -	m_pCall->SetHeader("SOAPAction", "servicename");
  -	/* End point URI too can be taken from WSDL */
  -	//m_pCall->SetEndpointURI("http://192.168.101.15:9999/axis/WebserviceDeployer");
  -	m_pCall->SetEndpointURI("http://127.0.0.1:9999/axis/WebserviceDeployer");
  -
  -	/* Following will establish the connections with the server too */
  -	if (SUCCESS != m_pCall->Initialize()) 
  -		return ret;
  -	m_pCall->SetSOAPVersion(SOAP_VER_1_1);
  -	/* This should be done before adding parameters or return type */
  -	
  -	m_pCall->SetOperation("deploy", "http://www.opensource.lk/");
  -	
  -	m_pCall->AddParameter(pAchServiceName, "ServiceName");
  -	m_pCall->AddParameter(pAchLibName, "LibName");
  +	do {
   
  -	Axis_Array* structAxis_Array= (Axis_Array*) malloc(sizeof(Axis_Array));
  +		chWSDDPath = argv[2];
   
  -	structAxis_Array->m_Array = sArrAllowedMethods;
  -	structAxis_Array->m_Size = iAllowdMethodsArraySize;
  -	m_pCall->AddParameter(structAxis_Array, XSD_STRING, "AllowedMethods");
  -	
  -	m_pCall->SetReturnType(XSD_INT);
  +		if (eADMIN_CLIENT_METHOD == AC_DEPLOY) {
  +			//chWSDDPath = "E:/axiscppdev/ws-axis/c/release/win32/deploy.wsdd";
  +			if ( processDeployWSDD(chWSDDPath) != SUCCESS ) {
  +				printMessage();
  +				break;
  +			}
  +		} else if (eADMIN_CLIENT_METHOD == AC_UNDEPLOY) {
  +			//chWSDDPath = "E:/axiscppdev/ws-axis/c/release/win32/undeploy.wsdd";
  +
  +			if ( processUnDeployWSDD(chWSDDPath) != SUCCESS ) {
  +				printMessage();
  +				break;
  +			}
  +		}
   
  -	
  -	nStatus = m_pCall->Invoke();
  +		/* The protocol can be taken from the binding section in the WSDL */
  +		m_pCall->SetProtocol(APTHTTP);
  +		/* The value for SOAPAction is specified in the binding section of the WSDL */
  +		m_pCall->SetHeader("SOAPAction", "servicename");
  +		/* End point URI too can be taken from WSDL */
  +		//m_pCall->SetEndpointURI("http://192.168.101.15:9999/axis/WebserviceDeployer");
  +		m_pCall->SetEndpointURI("http://127.0.0.1:9999/axis/WebserviceDeployer");
  +
  +		/* Following will establish the connections with the server too */
  +		if (SUCCESS != m_pCall->Initialize()) 
  +			return ret;
  +		m_pCall->SetSOAPVersion(SOAP_VER_1_1);
  +		/* This should be done before adding parameters or return type */
  +		
  +		if (eADMIN_CLIENT_METHOD == AC_DEPLOY) {
  +			m_pCall->SetOperation("deploy", "http://www.opensource.lk/");
  +		
  +			m_pCall->AddParameter(pAchServiceName, "ServiceName", XSD_STRING);
  +			m_pCall->AddParameter(pAchLibName, "LibName", XSD_STRING);
   
  -	if (SUCCESS == nStatus)
  -	{
  -		ret = m_pCall->GetResult()->GetInt();
  -#ifdef _DEBUG
  -		printf("%s%d", "Got The result = ", ret);
  -#endif
  -	}
  -	/* Following will close the connection with the server too */
  -	m_pCall->UnInitialize();
  +			Axis_Array* structAxis_Array= (Axis_Array*) malloc(sizeof(Axis_Array));
   
  -	delete m_pCall;
  +			structAxis_Array->m_Array = sArrAllowedMethods;
  +			structAxis_Array->m_Size = iAllowdMethodsArraySize;
  +			m_pCall->AddParameter(structAxis_Array, XSD_STRING, "AllowedMethods");
  +		} else if (eADMIN_CLIENT_METHOD == AC_UNDEPLOY) {
  +			m_pCall->SetOperation("undeploy", "http://www.opensource.lk/");
  +		
  +			m_pCall->AddParameter(pAchServiceName, "ServiceName", XSD_STRING);
  +		}
  +		
  +		m_pCall->SetReturnType(XSD_INT);
   
  +		
  +		nStatus = m_pCall->Invoke();
  +
  +		if (SUCCESS == nStatus)
  +		{
  +			ret = m_pCall->GetResult()->GetInt();
  +	#ifdef _DEBUG
  +			printf("%s%d\n", "Got The result = ", ret);
  +	#endif
  +			if (ret == 1) {
  +				if (eADMIN_CLIENT_METHOD == AC_DEPLOY) {
  +					printf("SUCCESS : Deployment is SUCCESSFULL");
  +				} else if (eADMIN_CLIENT_METHOD == AC_UNDEPLOY) {
  +					printf("SUCCESS : UnDeployment is SUCCESSFULL");
  +				}
  +			} else {
  +				if (eADMIN_CLIENT_METHOD == AC_DEPLOY) {
  +					printf("UNSUCCESS : Deployment is UNSUCCESSFULL");
  +				} else if (eADMIN_CLIENT_METHOD == AC_UNDEPLOY) {
  +					printf("UNSUCCESS : UnDeployment is UNSUCCESSFULL");
  +				}
  +			}
  +		}
  +
  +		/* Following will close the connection with the server too */
  +		m_pCall->UnInitialize();
  +
  +	} while(0);
  +
  +	delete m_pCall;
   
   	return 0;
   }
  @@ -138,34 +203,83 @@
   	/*
   	 *WSDD processing code comes here
   	 */
  +	int iStatus = FAIL;
  +
  +	do {
   
  -	WSDDDeployment* pWSDDDeployment= new WSDDDeployment();
  -	pWSDDDeployment->LoadWSDD(pchWSDDPath);
  +		WSDDDeployment* pWSDDDeployment= new WSDDDeployment();
  +		if (pWSDDDeployment->LoadWSDD(pchWSDDPath) != SUCCESS) {
  +			pchMessage = "Failed processing the given WSDD. Please check whether \n1) The wsdd exists
in the given path\
  +					\n2) The wsdd is correct etc\n";
  +			
  +			break;
  +		}
   
  -	const WSDDServiceMap* pWSDDServiceMap= pWSDDDeployment->GetWSDDServiceMap();
  -	const WSDDServiceMap::const_iterator itCurrService = pWSDDServiceMap->begin();	
  +		const WSDDServiceMap* pWSDDServiceMap= pWSDDDeployment->GetWSDDServiceMap();
  +		const WSDDServiceMap::const_iterator itCurrService = pWSDDServiceMap->begin();	
  +		
  +		if (itCurrService != pWSDDServiceMap->end()) {
  +			const WSDDService* pWSDDService = (*itCurrService).second;
  +			pAchServiceName = pWSDDService->GetServiceName();
  +			pAchLibName = pWSDDService->GetLibName();
  +			lstAllowedMethods = pWSDDService->getAllowedMethods();
  +			
  +			printf("pAchServiceName = %s\n", pAchServiceName);
  +			printf("pAchLibName = %s\n", pAchLibName);
  +			
  +			list<AxisString>::iterator iteAllowedMethods = lstAllowedMethods.begin();
  +			int iTmpCount =0;
  +			while (iteAllowedMethods != lstAllowedMethods.end()) {	
  +				/*DEBUG line
  +				printf("sAllowedMethod = %s\n", (*iteAllowedMethods).c_str());
  +				*/
  +				sArrAllowedMethods[iTmpCount] = (*iteAllowedMethods).c_str();
  +				iTmpCount++;
  +				iteAllowedMethods++;
  +			}
  +			iAllowdMethodsArraySize = iTmpCount;
  +		}
   	
  -	if (itCurrService != pWSDDServiceMap->end()) {
  -		const WSDDService* pWSDDService = (*itCurrService).second;
  -		pAchServiceName = pWSDDService->GetServiceName();
  -		pAchLibName = pWSDDService->GetLibName();
  -		lstAllowedMethods = pWSDDService->getAllowedMethods();
  -		
  -		printf("pAchServiceName = %s\n", pAchServiceName);
  -		printf("pAchLibName = %s\n", pAchLibName);
  -		
  -		list<AxisString>::iterator iteAllowedMethods = lstAllowedMethods.begin();
  -		int iTmpCount =0;
  -		while (iteAllowedMethods != lstAllowedMethods.end()) {	
  -			/*DEBUG line
  -			printf("sAllowedMethod = %s\n", (*iteAllowedMethods).c_str());
  -			*/
  -			sArrAllowedMethods[iTmpCount] = (*iteAllowedMethods).c_str();
  -			iTmpCount++;
  -			iteAllowedMethods++;
  +		iStatus = SUCCESS;
  +
  +	} while (0);
  +
  +	return iStatus;
  +}
  +
  +int processUnDeployWSDD(char* pchWSDDPath) {
  +
  +	/*
  +	 *WSDD processing code comes here
  +	 */
  +
  +	int iStatus = FAIL;
  +
  +	do {
  +
  +		WSDDDeployment* pWSDDDeployment= new WSDDDeployment();
  +		if (pWSDDDeployment->LoadWSDD(pchWSDDPath) != SUCCESS) {
  +			pchMessage = "Failed processing the given WSDD. Please check whether \n1) The wsdd exists
in the given path\
  +				\n2) The wsdd is correct etc\n";
  +			
  +			break;
   		}
  -		iAllowdMethodsArraySize = iTmpCount;
  -	}
   
  -	return SUCCESS;
  +		const WSDDServiceMap* pWSDDServiceMap= pWSDDDeployment->GetWSDDServiceMap();
  +		const WSDDServiceMap::const_iterator itCurrService = pWSDDServiceMap->begin();	
  +		
  +		if (itCurrService != pWSDDServiceMap->end()) {
  +			const WSDDService* pWSDDService = (*itCurrService).second;
  +			pAchServiceName = pWSDDService->GetServiceName();
  +		}
  +
  +		iStatus = SUCCESS;
  +
  +	} while (0);
  +
  +	return iStatus;
  +}
  +
  +void printMessage() {
  +	printf("Message : %s", pchMessage);
   }
  
  
  

Mime
View raw message