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 da...@apache.org on 2004/06/08 09:27:16 UTC

cvs commit: ws-axis/c/samples/client/rpcfault AxisDivByZeroException.cpp AxisDivByZeroException.h Makefile.am MathOps.cpp MathOps.h MathOpsClient.cpp

damitha     2004/06/08 00:27:16

  Modified:    c/samples/client/rpcfault AxisDivByZeroException.cpp
                        AxisDivByZeroException.h Makefile.am MathOps.cpp
                        MathOps.h MathOpsClient.cpp
  Log:
  
  
  Revision  Changes    Path
  1.2       +45 -67    ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.cpp
  
  Index: AxisDivByZeroException.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AxisDivByZeroException.cpp	24 May 2004 05:46:27 -0000	1.1
  +++ AxisDivByZeroException.cpp	8 Jun 2004 07:27:15 -0000	1.2
  @@ -1,78 +1,59 @@
  -/* -*- C++ -*- */
   /*
  - *   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  wsdl2ws generated
  + * This is the  implementation file genarated by WSDL2Ws tool.
  + * AxisDivByZeroException.cpp: implemtation for the AxisDivByZeroException.
    *
    */
   
   #include "AxisDivByZeroException.h"
  -#include <exception>
  -using namespace std;
   
  -/**
  - *    Default when no parameter passed. When thrown with no parameter
  - *    more general AXISC_DIVBYZERO_EXCEPTION is assumed.
  -*/
  +#include <axis/server/AxisWrapperAPI.h>
   
   AxisDivByZeroException::AxisDivByZeroException()
   {
  -    /* This only serves the pupose of indicating that the 
  -     * service has thrown an excpetion
  -     */
  -    m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
  -    processException(m_iExceptionCode);
  +/* This only serves the pupose of indicating that the 
  + * service has thrown an excpetion 
  + */ 
  +	m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; 
  +	processException(m_iExceptionCode); 
   }
   
  -AxisDivByZeroException::AxisDivByZeroException(SOAPStructFault* pFault)
  +AxisDivByZeroException::AxisDivByZeroException(DivByZeroStruct*pFault)
   {
  -    m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
  -    processException(pFault);
  -}
  +	m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
  +	processException(pFault);}
   
  -AxisDivByZeroException::AxisDivByZeroException (int iExceptionCode)
  +AxisDivByZeroException::AxisDivByZeroException(int iExceptionCode)
   {
  -    m_iExceptionCode = iExceptionCode;
  -    processException (iExceptionCode);
  +
  +	m_iExceptionCode = iExceptionCode;
  +	processException (iExceptionCode);
   }
   
  -AxisDivByZeroException::AxisDivByZeroException (exception* e)
  +AxisDivByZeroException::AxisDivByZeroException(exception* e)
   {
  -    processException (e);
  +	processException (e);
   }
   
  -AxisDivByZeroException::AxisDivByZeroException (exception* e, int iExceptionCode)
  +AxisDivByZeroException::AxisDivByZeroException(exception* e,int iExceptionCode)
   {
  -    processException (e, iExceptionCode);
  +
  +	processException (e, iExceptionCode);
   }
   
  -AxisDivByZeroException::~AxisDivByZeroException() throw ()
  +AxisDivByZeroException::~AxisDivByZeroException() throw () 
   {
  -        m_sMessage = "";
  +	m_sMessage ="";
   }
   
  -void AxisDivByZeroException::processException (exception* e, int iExceptionCode)
  +void AxisDivByZeroException:: processException(exception* e, int iExceptionCode)
   {
  -    m_sMessage = getMessage (e) + getMessage (iExceptionCode);
  +	m_sMessage = getMessage (e) + getMessage (iExceptionCode);
   }
   
  -void AxisDivByZeroException::processException (SOAPStructFault* pFault)
  +void AxisDivByZeroException::processException (DivByZeroStruct* pFault)
   {
  -    /*start user code*/
  -    int iSize = strlen(pFault->varString) + 8;
  +	/*User can do something like deserializing the struct into a string*/
  +        int iSize = strlen(pFault->varString) + 8;
       char* sMessage = (char*) malloc(iSize);
       m_sMessage = (char*) malloc(iSize);
       char carrTempBuff[4];
  @@ -86,47 +67,44 @@
       strcat(sMessage, "\n");
       m_sMessage = sMessage;
       free(sMessage);
  -    /*end user code*/
   }
   
  -void AxisDivByZeroException::processException (exception* e)
  +void AxisDivByZeroException::processException(exception* e)
   {
  -    m_sMessage = getMessage (e);
  +	m_sMessage = getMessage (e);
   }
   
   void AxisDivByZeroException::processException(int iExceptionCode)
   {
  -    m_sMessage = getMessage (iExceptionCode);
  +	m_sMessage = getMessage (iExceptionCode);
   }
   
   const string AxisDivByZeroException::getMessage (exception* objException)
   {
  -    string sMessage = objException->what();
  -
  -    return sMessage;
  +	string sMessage = objException->what();
  +	return sMessage;
   }
   
   const string AxisDivByZeroException::getMessage (int iExceptionCode)
   {
  -    string sMessage;
  -    switch(iExceptionCode)
  -    {
  -        case AXISC_SERVICE_THROWN_EXCEPTION:
  -            sMessage = "A service has thrown an exception. see detail";
  -            break;
  -        default:
  -            sMessage = "Unknown Exception has occured";
  -    }
  -    return sMessage;
  +	string sMessage;
  +	switch(iExceptionCode)
  +	{
  +		case AXISC_SERVICE_THROWN_EXCEPTION:
  +		sMessage = "A service has thrown an exception. see detail";
  +		break;
  +		default:
  +		sMessage = "Unknown Exception has occured";
  +	}
  +return sMessage;
   }
   
   const char* AxisDivByZeroException::what() throw ()
   {
  -    return m_sMessage.c_str ();
  +	return m_sMessage.c_str ();
   }
   
  -const int AxisDivByZeroException::getExceptionCode()
  -{
  -    return m_iExceptionCode;
  +const int AxisDivByZeroException::getExceptionCode(){
  +	return m_iExceptionCode;
   }
   
  
  
  
  1.2       +24 -42    ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.h
  
  Index: AxisDivByZeroException.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/AxisDivByZeroException.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AxisDivByZeroException.h	24 May 2004 05:46:27 -0000	1.1
  +++ AxisDivByZeroException.h	8 Jun 2004 07:27:15 -0000	1.2
  @@ -1,56 +1,38 @@
   /*
  - *   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 wsdl2ws generated
  + * This is the Client Stub Class genarated by the tool WSDL2Ws
  + * AxisDivByZeroException.h: interface for the AxisDivByZeroExceptionclass.
    *
    */
  - 
  -#ifndef __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
  -#define __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
  +#if !defined(__AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_)
  +#define __AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_
   
   #include <string>
   #include <exception>
   #include <axis/server/AxisException.h>
  -#include "SOAPStructFault.h"
  +#include "DivByZeroStruct.h"
   
   using namespace std;
  -
  -class AxisDivByZeroException : public AxisException
  +class AxisDivByZeroException: public AxisException
   {
  -
   public:
  -    AxisDivByZeroException();
  -    AxisDivByZeroException(SOAPStructFault* pFault);
  -    AxisDivByZeroException(int iExceptionCode);
  -    AxisDivByZeroException(exception* e);
  -    AxisDivByZeroException(exception* e, int iExceptionCode);
  -    virtual ~AxisDivByZeroException() throw();
  -    const char* what() throw();
  -    const int getExceptionCode();
  -    const string getMessage(exception* e);
  -    const string getMessage(int iExceptionCode);
  -                                                                                                                             
  +	AxisDivByZeroException();
  +	AxisDivByZeroException(DivByZeroStruct* pFault);
  +	AxisDivByZeroException(int iExceptionCode);
  +	AxisDivByZeroException(exception* e);
  +	AxisDivByZeroException(exception* e, int iExceptionCode);
  +	virtual ~AxisDivByZeroException() throw();
  +	 const char* what() throw();
  +	 const int getExceptionCode();
  +	 const string getMessage(exception* e);
  +	 const string getMessage(int iExceptionCode);
   private:
  -    void processException(exception* e);
  -    void processException(SOAPStructFault* pFault);
  -    void processException(exception* e, int iExceptionCode);
  -    void processException(int iExceptionCode);
  -    string m_sMessage;
  -    int m_iExceptionCode;
  -};
  +	 void processException(exception* e);
  +	 void processException(DivByZeroStruct* pFault);
  +	 void processException(exception* e, int iExceptionCode);
  +	 void processException(int iExceptionCode);
  +	 string m_sMessage;
  +	 int m_iExceptionCode;
   
  -#endif
  +};
   
  +#endif /* !defined(__AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_)*/
  
  
  
  1.4       +1 -1      ws-axis/c/samples/client/rpcfault/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/Makefile.am,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile.am	24 May 2004 05:44:19 -0000	1.3
  +++ Makefile.am	8 Jun 2004 07:27:15 -0000	1.4
  @@ -3,7 +3,7 @@
   AM_CPPFLAGS = $(CPPFLAGS)
   mathops_SOURCES = MathOps.cpp \
                     MathOpsClient.cpp \
  -                  SOAPStructFault.cpp \
  +                  DivByZeroStruct.cpp \
                     AxisDivByZeroException.cpp
   mathops_LDADD   =  $(LDFLAGS)
   INCLUDES = -I$(AXISCPP_HOME)/include
  
  
  
  1.10      +77 -79    ws-axis/c/samples/client/rpcfault/MathOps.cpp
  
  Index: MathOps.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/MathOps.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MathOps.cpp	8 Jun 2004 05:22:53 -0000	1.9
  +++ MathOps.cpp	8 Jun 2004 07:27:15 -0000	1.10
  @@ -1,6 +1,8 @@
   /*
    * This is the Client Stub implementation file genarated by WSDL2Ws tool.
    * MathOps.cpp: implemtation for the MathOps.
  +* Default when no parameter passed. When thrown with no parameter 
  +more general MathOps  is assumed.
    *
    */
   
  @@ -8,27 +10,21 @@
   
   #include <axis/server/AxisWrapperAPI.h>
   
  -extern int Axis_DeSerialize_SOAPStructFault(SOAPStructFault* param,
  -    IWrapperSoapDeSerializer *pDZ);
  -                                                                                                                             
  -extern void* Axis_Create_SOAPStructFault(SOAPStructFault *Obj, bool bArray = false,
  -    int nSize=0);
  -                                                                                                                             
  -extern void Axis_Delete_SOAPStructFault(SOAPStructFault* param, bool bArray = false,
  -    int nSize=0);
  -                                                                                                                             
  -extern int Axis_Serialize_SOAPStructFault(SOAPStructFault* param, IWrapperSoapSerializer* pSZ,
  -    bool bArray = false);
  -                                                                                                                             
  -extern int Axis_GetSize_SOAPStructFault();
  +using namespace std;
   
  -bool CallBase::bInitialized;
  + bool CallBase::bInitialized;
   CallFunctions CallBase::ms_VFtable;
  -MathOps::MathOps(const char* pchEndpointUri)
  +extern int Axis_DeSerialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapDeSerializer *pDZ);
  +extern void* Axis_Create_DivByZeroStruct(DivByZeroStruct *Obj, bool bArray = false, int nSize=0);
  +extern void Axis_Delete_DivByZeroStruct(DivByZeroStruct* param, bool bArray = false, int nSize=0);
  +extern int Axis_Serialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
  +extern int Axis_GetSize_DivByZeroStruct();
  +
  +MathOps::MathOps()
   {
   	m_pCall = new Call();
   	m_pCall->setProtocol(APTHTTP);
  -	m_pCall->setEndpointURI(pchEndpointUri);
  +	m_pCall->setEndpointURI("http://localhost:5555/axis/MathOps");
   }
   
   MathOps::~MathOps()
  @@ -40,76 +36,78 @@
   /*Methods corresponding to the web service methods*/
   
   /*
  - * This method wrap the service methoddiv
  + * This method wrap the service method div
    */
   int MathOps::div(int Value0, int Value1)
   {
  -    int Ret;
  -    char* cFaultcode;
  -    char* cFaultstring;
  -    char* cFaultactor;
  -    char* cFaultdetail;
  -    try
  -    {
  -        if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) return Ret;
  -	m_pCall->setTransportProperty(SOAPACTION_HEADER , "MathOps#div");
  -	m_pCall->setSOAPVersion(SOAP_VER_1_1);
  -	m_pCall->setOperation("div", "http://localhost/axis/MathOps");
  -	m_pCall->addParameter((void*)&Value0, "in0", XSD_INT);
  -	m_pCall->addParameter((void*)&Value1, "in1", XSD_INT);
  -	if (AXIS_SUCCESS == m_pCall->invoke())
  +	int Ret;
  +	char* cFaultcode;
  +	char* cFaultstring;
  +	char* cFaultactor;
  +	char* cFaultdetail;
  +	try
  +	{
  +		if (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL)) 
  +			return Ret;
  +		m_pCall->setTransportProperty(SOAPACTION_HEADER , "MathOps#div");
  +		m_pCall->setSOAPVersion(SOAP_VER_1_1);
  +		m_pCall->setOperation("div", "http://soapinterop.org/wsdl");
  +		m_pCall->addParameter((void*)&Value0, "int0", XSD_INT);
  +		m_pCall->addParameter((void*)&Value1, "int1", XSD_INT);
  +		if (AXIS_SUCCESS == m_pCall->invoke())
  +		{
  +			if(AXIS_SUCCESS == m_pCall->checkMessage("divResponse", "http://soapinterop.org/wsdl"))
  +			{
  +				Ret = m_pCall->getElementAsInt("addReturn", 0);
  +			}
  +		}
  +		m_pCall->unInitialize();
  +		return Ret;
  +	}
  +	catch(AxisException& e)
   	{
  -	    if(AXIS_SUCCESS == m_pCall->checkMessage("divResponse",
  -                "http://localhost/axis/MathOps"))
  -	    {
  -	        Ret = m_pCall->getElementAsInt("addReturn", 0);
  -	    }
  -        }
  -    }
  -    catch(AxisException& e)
  -    {
  -        if(AXIS_SUCCESS == m_pCall->checkFault("Fault",
  -            "http://localhost/axis/MathOps")) //Exception handling code goes here
  -        {
  -            cFaultcode = m_pCall->getElementAsString("faultcode", 0);
  -            cFaultstring = m_pCall->getElementAsString("faultstring", 0); 
  -            cFaultactor = m_pCall->getElementAsString("faultactor", 0);
  -            if(0 == strcmp("SOAPStructFault", cFaultstring))
  -            {
  -                if(AXIS_SUCCESS == m_pCall->checkFault("faultdetail",
  -                    "http://localhost/axis/MathOps"))
  -                {
  -                    SOAPStructFault* pFaultDetail = NULL;
  -                    pFaultDetail = (SOAPStructFault*)m_pCall->
  -                    getCmplxObject((void*) Axis_DeSerialize_SOAPStructFault, 
  -                        (void*) Axis_Create_SOAPStructFault, 
  -                        (void*) Axis_Delete_SOAPStructFault,"faultstruct", 0);
  -
  -                    /*start user code*/
  -                    char* temp = pFaultDetail->varString;
  -                    printf("%s\n", temp);
  -                    printf("faultcode:%s\n", cFaultcode);
  -                    printf("faultstring:%s\n", cFaultstring);
  -                    printf("faultactor:%s\n", cFaultactor);
  -                    /*end user code*/
  -                    m_pCall->unInitialize();
  -                    throw AxisDivByZeroException(pFaultDetail);
  -                }
  -            }
  -            else//fault detail consists of a simple string
  -            {
  -                cFaultdetail = m_pCall->getElementAsString("faultdetail", 0);
  -                throw AxisException(cFaultdetail);
  -            }
  -        }
  -        else throw;
  -    }
  -    m_pCall->unInitialize();
  -    return Ret;
  +		if (AXIS_SUCCESS == m_pCall->checkFault("Fault","http://localhost/axis/MathOps" ))//Exception handling code goes here
  +		{
  +			cFaultcode = m_pCall->getElementAsString("faultcode", 0);
  +			cFaultstring = m_pCall->getElementAsString("faultstring", 0);
  +			cFaultactor = m_pCall->getElementAsString("faultactor", 0);
  +			if(0 == strcmp("DivByZeroStruct", cFaultstring))
  +			{
  +				if (AXIS_SUCCESS == m_pCall->checkFault("faultdetail","http://localhost/axis/MathOps"))
  +				{
  +					DivByZeroStruct* pFaultDetail = NULL;
  +					pFaultDetail = (DivByZeroStruct*)m_pCall->
  +						getCmplxObject((void*) Axis_DeSerialize_DivByZeroStruct,
  +						(void*) Axis_Create_DivByZeroStruct,
  +						(void*) Axis_Delete_DivByZeroStruct,"faultstruct1", 0);
  +					/*User code to handle the struct can be inserted here*/
  +                                        printf("faultcode:%s\n", cFaultcode);
  +                                        printf("faultstring:%s\n", cFaultstring);
  +                                        printf("faultactor:%s\n", cFaultactor);
  +					m_pCall->unInitialize();
  +					throw AxisDivByZeroException(pFaultDetail);
  +				}
  +			}
  +			else
  +			{
  +				  cFaultdetail = m_pCall->getElementAsString("faultdetail", 0);
  +				  throw AxisException(cFaultdetail);
  +			}
  +		}
  +		else throw;
  +	}
  +}
  +
  +int MathOps::getStatus()
  +{
  +	if ( m_pCall==NULL ) 
  +		return AXIS_SUCCESS; 
  +	else 
  +		return m_pCall->getStatus();
   }
   
   int MathOps::getFaultDetail(char** ppcDetail)
   {
  -    m_pCall->getFaultDetail(ppcDetail);
  +	return m_pCall->getFaultDetail(ppcDetail);
   }
   
  
  
  
  1.4       +8 -7      ws-axis/c/samples/client/rpcfault/MathOps.h
  
  Index: MathOps.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/MathOps.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MathOps.h	24 May 2004 05:44:19 -0000	1.3
  +++ MathOps.h	8 Jun 2004 07:27:15 -0000	1.4
  @@ -3,25 +3,26 @@
    * MathOps.h: interface for the MathOpsclass.
    *
    */
  -#if !defined(__MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_)
  -#define __MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_
  +#if !defined(__MATHOPS_CLIENTSTUB_H__INCLUDED_)
  +#define __MATHOPS_CLIENTSTUB_H__INCLUDED_
   
   #include <axis/client/Call.h>
  -#include "SOAPStructFault.h"
  +/*include Exception header files here*/
   #include "AxisDivByZeroException.h"
  -#include <ctype.h>
  +#include "DivByZeroStruct.h"
   
   class MathOps 
   {
   private:
   	Call* m_pCall;
   public:
  -	MathOps(const char* pchEndpointUri);
  +	MathOps();
   public:
   	virtual ~MathOps();
   public: 
   	int div(int Value0,int Value1);
  -        int getFaultDetail(char** ppcDetail);
  +	int getStatus();
  +	int getFaultDetail(char** ppcDetail);
   };
   
  -#endif /* !defined(__MATHOPS_CLIENTSTUB_H__OF_AXIS_INCLUDED_)*/
  +#endif /* !defined(__MATHOPS_CLIENTSTUB_H__INCLUDED_)*/
  
  
  
  1.5       +2 -1      ws-axis/c/samples/client/rpcfault/MathOpsClient.cpp
  
  Index: MathOpsClient.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/samples/client/rpcfault/MathOpsClient.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MathOpsClient.cpp	24 May 2004 05:44:19 -0000	1.4
  +++ MathOpsClient.cpp	8 Jun 2004 07:27:15 -0000	1.5
  @@ -1,5 +1,6 @@
   #include "MathOps.h"
   #include <axis/server/AxisException.h>
  +#include <ctype.h>
   
   void PrintUsage();
   bool IsNumber(const char* p);
  @@ -27,7 +28,7 @@
   	}
   	printf("Sending Requests to Server http://%s:%s ........\n\n", server, port);
   	sprintf(endpoint, "http://%s:%s/axis/MathOps", server, port);
  -	MathOps ws(endpoint);
  +	MathOps ws;
   
   	op = argv[3];
   	p1 = argv[4];