You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2004/06/22 14:18:27 UTC
cvs commit: ws-axis/c/tests/server/exceptionTest AxisDivByZeroException.cpp AxisDivByZeroException.h AxisNormalDetailException.cpp AxisNormalDetailException.h AxisOutOfBoundException.cpp AxisOutOfBoundException.h DivByZeroStruct.cpp DivByZeroStruct.h Makefile.am MathOps.cpp MathOps.h MathOps.wsdl MathOpsService.cpp MathOpsWrapper.cpp MathOpsWrapper.h OutOfBoundStruct.cpp OutOfBoundStruct.h SpecialDetailStruct.cpp SpecialDetailStruct.h deploy.wsdd undeploy.wsdd
damitha 2004/06/22 05:18:27
Added: c/tests/server Makefile.am configure.ac
c/tests/server/exceptionTest AxisDivByZeroException.cpp
AxisDivByZeroException.h
AxisNormalDetailException.cpp
AxisNormalDetailException.h
AxisOutOfBoundException.cpp
AxisOutOfBoundException.h DivByZeroStruct.cpp
DivByZeroStruct.h Makefile.am MathOps.cpp MathOps.h
MathOps.wsdl MathOpsService.cpp MathOpsWrapper.cpp
MathOpsWrapper.h OutOfBoundStruct.cpp
OutOfBoundStruct.h SpecialDetailStruct.cpp
SpecialDetailStruct.h deploy.wsdd undeploy.wsdd
Log:
Server side testing sample for exception handling and fault mapping
Revision Changes Path
1.1 ws-axis/c/tests/server/Makefile.am
Index: Makefile.am
===================================================================
SUBDIRS = exceptionTest
1.1 ws-axis/c/tests/server/configure.ac
Index: configure.ac
===================================================================
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE(0.3)
AM_CONFIG_HEADER(config.h)
CFLAGS="-Wshadow -Wall -pedantic -ansi"
CPPFLAGS="-Wshadow -Wall -pedantic -ansi"
LDFLAGS="-s -ldl -lstdc++"
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_OUTPUT(Makefile exceptionTest/Makefile)
1.1 ws-axis/c/tests/server/exceptionTest/AxisDivByZeroException.cpp
Index: AxisDivByZeroException.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains implementations of an Exception class of the web service.
*/
#include "AxisDivByZeroException.h"
#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);
}
AxisDivByZeroException::AxisDivByZeroException(DivByZeroStruct*pFault)
{
m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
processException(pFault);}
AxisDivByZeroException::AxisDivByZeroException(int iExceptionCode)
{
m_iExceptionCode = iExceptionCode;
processException (iExceptionCode);
}
AxisDivByZeroException::AxisDivByZeroException(exception* e)
{
processException (e);
}
AxisDivByZeroException::AxisDivByZeroException(exception* e,int iExceptionCode)
{
processException (e, iExceptionCode);
}
AxisDivByZeroException::~AxisDivByZeroException() throw ()
{
m_sMessage ="";
}
void AxisDivByZeroException:: processException(exception* e, int iExceptionCode)
{
m_sMessage = getMessage (e) + getMessage (iExceptionCode);
}
void AxisDivByZeroException::processException (DivByZeroStruct* pFault)
{
/*User can do something like deserializing the struct into a string*/}
void AxisDivByZeroException::processException(exception* e)
{
m_sMessage = getMessage (e);
}
void AxisDivByZeroException::processException(int iExceptionCode)
{
m_sMessage = getMessage (iExceptionCode);
}
const string AxisDivByZeroException::getMessage (exception* objException)
{
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;
}
const char* AxisDivByZeroException::what() throw ()
{
return m_sMessage.c_str ();
}
const int AxisDivByZeroException::getExceptionCode(){
return m_iExceptionCode;
}
1.1 ws-axis/c/tests/server/exceptionTest/AxisDivByZeroException.h
Index: AxisDivByZeroException.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains an Exception class of the web service.
*/
#if !defined(__AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_)
#define __AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_
#include <string>
#include <exception>
#include <axis/server/AxisException.h>
#include "DivByZeroStruct.h"
using namespace std;
class AxisDivByZeroException: public AxisException
{
public:
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(DivByZeroStruct* pFault);
void processException(exception* e, int iExceptionCode);
void processException(int iExceptionCode);
string m_sMessage;
int m_iExceptionCode;
};
#endif /* !defined(__AXISDIVBYZEROEXCEPTION_EXCEPTION_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/AxisNormalDetailException.cpp
Index: AxisNormalDetailException.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains implementations of an Exception class of the web service.
*/
#include "AxisNormalDetailException.h"
#include <axis/server/AxisWrapperAPI.h>
AxisNormalDetailException::AxisNormalDetailException()
{
/* This only serves the pupose of indicating that the
* service has thrown an excpetion
*/
m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
processException(m_iExceptionCode);
}
AxisNormalDetailException::AxisNormalDetailException(SpecialDetailStruct*pFault)
{
m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
processException(pFault);}
AxisNormalDetailException::AxisNormalDetailException(int iExceptionCode)
{
m_iExceptionCode = iExceptionCode;
processException (iExceptionCode);
}
AxisNormalDetailException::AxisNormalDetailException(exception* e)
{
processException (e);
}
AxisNormalDetailException::AxisNormalDetailException(exception* e,int iExceptionCode)
{
processException (e, iExceptionCode);
}
AxisNormalDetailException::~AxisNormalDetailException() throw ()
{
m_sMessage ="";
}
void AxisNormalDetailException:: processException(exception* e, int iExceptionCode)
{
m_sMessage = getMessage (e) + getMessage (iExceptionCode);
}
void AxisNormalDetailException::processException (SpecialDetailStruct* pFault)
{
/*User can do something like deserializing the struct into a string*/}
void AxisNormalDetailException::processException(exception* e)
{
m_sMessage = getMessage (e);
}
void AxisNormalDetailException::processException(int iExceptionCode)
{
m_sMessage = getMessage (iExceptionCode);
}
const string AxisNormalDetailException::getMessage (exception* objException)
{
string sMessage = objException->what();
return sMessage;
}
const string AxisNormalDetailException::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;
}
const char* AxisNormalDetailException::what() throw ()
{
return m_sMessage.c_str ();
}
const int AxisNormalDetailException::getExceptionCode(){
return m_iExceptionCode;
}
1.1 ws-axis/c/tests/server/exceptionTest/AxisNormalDetailException.h
Index: AxisNormalDetailException.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains an Exception class of the web service.
*/
#if !defined(__AXISNORMALDETAILEXCEPTION_EXCEPTION_H__INCLUDED_)
#define __AXISNORMALDETAILEXCEPTION_EXCEPTION_H__INCLUDED_
#include <string>
#include <exception>
#include <axis/server/AxisException.h>
#include "SpecialDetailStruct.h"
using namespace std;
class AxisNormalDetailException: public AxisException
{
public:
AxisNormalDetailException();
AxisNormalDetailException(SpecialDetailStruct* pFault);
AxisNormalDetailException(int iExceptionCode);
AxisNormalDetailException(exception* e);
AxisNormalDetailException(exception* e, int iExceptionCode);
virtual ~AxisNormalDetailException() 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(SpecialDetailStruct* pFault);
void processException(exception* e, int iExceptionCode);
void processException(int iExceptionCode);
string m_sMessage;
int m_iExceptionCode;
};
#endif /* !defined(__AXISNORMALDETAILEXCEPTION_EXCEPTION_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/AxisOutOfBoundException.cpp
Index: AxisOutOfBoundException.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains implementations of an Exception class of the web service.
*/
#include "AxisOutOfBoundException.h"
#include <axis/server/AxisWrapperAPI.h>
AxisOutOfBoundException::AxisOutOfBoundException()
{
/* This only serves the pupose of indicating that the
* service has thrown an excpetion
*/
m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
processException(m_iExceptionCode);
}
AxisOutOfBoundException::AxisOutOfBoundException(OutOfBoundStruct*pFault)
{
m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION;
processException(pFault);}
AxisOutOfBoundException::AxisOutOfBoundException(int iExceptionCode)
{
m_iExceptionCode = iExceptionCode;
processException (iExceptionCode);
}
AxisOutOfBoundException::AxisOutOfBoundException(exception* e)
{
processException (e);
}
AxisOutOfBoundException::AxisOutOfBoundException(exception* e,int iExceptionCode)
{
processException (e, iExceptionCode);
}
AxisOutOfBoundException::~AxisOutOfBoundException() throw ()
{
m_sMessage ="";
}
void AxisOutOfBoundException:: processException(exception* e, int iExceptionCode)
{
m_sMessage = getMessage (e) + getMessage (iExceptionCode);
}
void AxisOutOfBoundException::processException (OutOfBoundStruct* pFault)
{
/*User can do something like deserializing the struct into a string*/}
void AxisOutOfBoundException::processException(exception* e)
{
m_sMessage = getMessage (e);
}
void AxisOutOfBoundException::processException(int iExceptionCode)
{
m_sMessage = getMessage (iExceptionCode);
}
const string AxisOutOfBoundException::getMessage (exception* objException)
{
string sMessage = objException->what();
return sMessage;
}
const string AxisOutOfBoundException::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;
}
const char* AxisOutOfBoundException::what() throw ()
{
return m_sMessage.c_str ();
}
const int AxisOutOfBoundException::getExceptionCode(){
return m_iExceptionCode;
}
1.1 ws-axis/c/tests/server/exceptionTest/AxisOutOfBoundException.h
Index: AxisOutOfBoundException.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains an Exception class of the web service.
*/
#if !defined(__AXISOUTOFBOUNDEXCEPTION_EXCEPTION_H__INCLUDED_)
#define __AXISOUTOFBOUNDEXCEPTION_EXCEPTION_H__INCLUDED_
#include <string>
#include <exception>
#include <axis/server/AxisException.h>
#include "OutOfBoundStruct.h"
using namespace std;
class AxisOutOfBoundException: public AxisException
{
public:
AxisOutOfBoundException();
AxisOutOfBoundException(OutOfBoundStruct* pFault);
AxisOutOfBoundException(int iExceptionCode);
AxisOutOfBoundException(exception* e);
AxisOutOfBoundException(exception* e, int iExceptionCode);
virtual ~AxisOutOfBoundException() 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(OutOfBoundStruct* pFault);
void processException(exception* e, int iExceptionCode);
void processException(int iExceptionCode);
string m_sMessage;
int m_iExceptionCode;
};
#endif /* !defined(__AXISOUTOFBOUNDEXCEPTION_EXCEPTION_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/DivByZeroStruct.cpp
Index: DivByZeroStruct.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type DivByZeroStruct
*/
#include <malloc.h>
#include "DivByZeroStruct.h"
#include <axis/server/AxisWrapperAPI.h>
/*
* This static method serialize a DivByZeroStruct type of object
*/
int Axis_Serialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false)
{
if (bArray)
{
pSZ->serialize("<", Axis_TypeName_DivByZeroStruct, ">", NULL);
}
else
{
const AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_DivByZeroStruct);
pSZ->serialize("<", Axis_TypeName_DivByZeroStruct, " xsi:type=\"", sPrefix, ":",
Axis_TypeName_DivByZeroStruct, "\" xmlns:", sPrefix, "=\"",
Axis_URI_DivByZeroStruct, "\">", NULL);
}
pSZ->serializeAsElement("varString", (void*)&(param->varString), XSD_STRING);
pSZ->serializeAsElement("varInt", (void*)&(param->varInt), XSD_INT);
pSZ->serializeAsElement("varFloat", (void*)&(param->varFloat), XSD_FLOAT);
pSZ->serialize("</", Axis_TypeName_DivByZeroStruct, ">", NULL);
return AXIS_SUCCESS;
}
/*
* This static method deserialize a DivByZeroStruct type of object
*/
int Axis_DeSerialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapDeSerializer* pIWSDZ)
{
param->varString = pIWSDZ->getElementAsString("varString",0);
param->varInt = pIWSDZ->getElementAsInt("varInt",0);
param->varFloat = pIWSDZ->getElementAsFloat("varFloat",0);
return pIWSDZ->getStatus();
}
void* Axis_Create_DivByZeroStruct(DivByZeroStruct* pObj, bool bArray = false, int nSize=0)
{
if (bArray && (nSize > 0))
{
if (pObj)
{
DivByZeroStruct* pNew = new DivByZeroStruct[nSize];
memcpy(pNew, pObj, sizeof(DivByZeroStruct)*nSize/2);
memset(pObj, 0, sizeof(DivByZeroStruct)*nSize/2);
delete [] pObj;
return pNew;
}
else
{
return new DivByZeroStruct[nSize];
}
}
else
return new DivByZeroStruct;
}
/*
* This static method delete a DivByZeroStruct type of object
*/
void Axis_Delete_DivByZeroStruct(DivByZeroStruct* param, bool bArray = false, int nSize=0)
{
if (bArray)
{
delete [] param;
}
else
{
delete param;
}
}
/*
* This static method gives the size of DivByZeroStruct type of object
*/
int Axis_GetSize_DivByZeroStruct()
{
return sizeof(DivByZeroStruct);
}
DivByZeroStruct::DivByZeroStruct()
{
/*do not allocate memory to any pointer members here
because deserializer will allocate memory anyway. */
}
DivByZeroStruct::~DivByZeroStruct()
{
/*delete any pointer and array members here*/
}
1.1 ws-axis/c/tests/server/exceptionTest/DivByZeroStruct.h
Index: DivByZeroStruct.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type DivByZeroStruct
*/
#if !defined(__DIVBYZEROSTRUCT_PARAM_H__INCLUDED_)
#define __DIVBYZEROSTRUCT_PARAM_H__INCLUDED_
#include <axis/server/AxisUserAPI.h>
/*Local name and the URI for the type*/
static const char* Axis_URI_DivByZeroStruct = "http://soapinterop.org/types";
static const char* Axis_TypeName_DivByZeroStruct = "DivByZeroStruct";
class DivByZeroStruct
{
public:
xsd__string varString;
int varInt;
float varFloat;
DivByZeroStruct();
virtual ~DivByZeroStruct();
};
#endif /* !defined(__DIVBYZEROSTRUCT_PARAM_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/Makefile.am
Index: Makefile.am
===================================================================
lib_LTLIBRARIES = libmathops.la
SUBDIRS =
libmathops_la_SOURCES = AxisDivByZeroException.cpp \
AxisNormalDetailException.cpp \
AxisOutOfBoundException.cpp \
OutOfBoundStruct.cpp \
SpecialDetailStruct.cpp \
DivByZeroStruct.cpp \
MathOpsService.cpp \
MathOps.cpp \
MathOpsWrapper.cpp
libmathops_la_LIBADD = $(LDFLAGS)
INCLUDES = -I$(AXISCPP_HOME)/include
1.1 ws-axis/c/tests/server/exceptionTest/MathOps.cpp
Index: MathOps.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains definitions of the web service
*/
#include "MathOps.h"
MathOps::MathOps()
{
}
MathOps::~MathOps()
{
}
int MathOps::div(int Value0, int Value1)
{
if (Value1 == 0) throw AxisDivByZeroException();
if(Value0 < 0 || Value1 < 0) throw AxisOutOfBoundException();
if(Value0 == 1000) throw AxisNormalDetailException();
return Value0/Value1;
}
1.1 ws-axis/c/tests/server/exceptionTest/MathOps.h
Index: MathOps.h
===================================================================
/*
* This is the Service Class genarated by the tool WSDL2Ws
* MathOps.h: interface for the MathOpsclass.
*
*/
#if !defined(__MATHOPS_SERVERSKELETON_H__INCLUDED_)
#define __MATHOPS_SERVERSKELETON_H__INCLUDED_
#include <axis/server/AxisUserAPI.h>
#include "DivByZeroStruct.h"
#include "SpecialDetailStruct.h"
#include "OutOfBoundStruct.h"
#include "AxisOutOfBoundException.h"
#include "AxisDivByZeroException.h"
#include "AxisNormalDetailException.h"
class MathOps
{
public:
MathOps();
public:
virtual ~MathOps();
public:
int div(int Value0,int Value1);
};
#endif /* !defined(__MATHOPS_SERVERSKELETON_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/MathOps.wsdl
Index: MathOps.wsdl
===================================================================
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://soapinterop.org/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/wsdl">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://soapinterop.org/types">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="DivByZeroStruct">
<sequence>
<element name="varString" type="xsd:string"/>
<element name="varInt" type="xsd:int"/>
<element name="varFloat" type="xsd:float"/>
</sequence>
</complexType>
<complexType name="SpecialDetailStruct">
<sequence>
<element name="varString" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="OutOfBoundStruct">
<sequence>
<element name="varString" type="xsd:string"/>
<element name="varInt" type="xsd:int"/>
<element name="specialDetail" type="tns:SpecialDetailStruct"/>
</sequence>
</complexType>
</schema>
</types>
<message name="DivByZeroFault">
<part name="faultstruct1" type="ns2:DivByZeroStruct"/>
</message>
<message name="OutOfBoundFault">
<part name="faultstruct1" type="ns2:OutOfBoundStruct"/>
</message>
<message name="SpecialDetailFault">
<part name="faultstruct1" type="ns2:SpecialDetailStruct"/>
</message>
<message name="divRequest">
<part name="int0" type="xsd:int"/>
<part name="int1" type="xsd:int"/>
</message>
<message name="divResponse">
<part name="addReturn" type="xsd:int"/>
</message>
<portType name="MathOps">
<operation name="div" parameterOrder ="int0 int1">
<input message="tns:divRequest"/>
<output message="tns:divResponse"/>
<fault name="DivByZero" message="tns:DivByZeroFault"/>
<fault name="OutOfBound" message="tns:OutOfBoundFault"/>
<fault name="NormalDetail" message="tns:SpecialDetailFault"/>
</operation>
</portType>
<binding name="MathOpsBinding" type="tns:MathOps">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="div">
<soap:operation soapAction="MathOps#div"/>
<input name="divRequest">
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/axis/MathOps"
use="encoded"/>
</input>
<output name="divResponse">
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/axis/MathOps"
use="encoded"/>
</output>
<fault name="DivByZero">
<soap:fault name="DivByZero" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soapinterop.org/wsdl"/>
</fault>
<fault name="OutOfBound">
<soap:fault name="OutOfBound" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soapinterop.org/wsdl"/>
</fault>
<fault name="NormalDetail">
<soap:fault name="NormalDetail" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://soapinterop.org/wsdl"/>
</fault>
</operation>
</binding>
<service name="MathOpsService">
<port name="MathOps" binding="tns:MathOpsBinding">
<soap:address location="http://localhost/axis/MathOps"/>
</port>
</service>
<!-- Fault messages -->
</definitions>
1.1 ws-axis/c/tests/server/exceptionTest/MathOpsService.cpp
Index: MathOpsService.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains the two export functions of the Web service Dynamic Library
*/
#include "MathOpsWrapper.h"
extern "C" {
STORAGE_CLASS_INFO
int GetClassInstance(BasicHandler **inst)
{
*inst = new BasicHandler();
WrapperClassHandler* pWCH = new MathOpsWrapper();
(*inst)->_functions = 0;
if (pWCH)
{
(*inst)->_object = pWCH;
return pWCH->init();
}
return AXIS_FAIL;
}
STORAGE_CLASS_INFO
int DestroyInstance(BasicHandler *inst)
{
if (inst)
{
WrapperClassHandler* pWCH = reinterpret_cast<WrapperClassHandler*>(inst);
pWCH->fini();
delete pWCH;
delete inst;
return AXIS_SUCCESS;
}
return AXIS_FAIL;
}
}
1.1 ws-axis/c/tests/server/exceptionTest/MathOpsWrapper.cpp
Index: MathOpsWrapper.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Web Service Wrapper implementations
*/
#include "MathOpsWrapper.h"
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();
extern int Axis_DeSerialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapDeSerializer* pDZ);
extern void* Axis_Create_SpecialDetailStruct(SpecialDetailStruct *Obj, bool bArray = false, int nSize=0);
extern void Axis_Delete_SpecialDetailStruct(SpecialDetailStruct* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
extern int Axis_GetSize_SpecialDetailStruct();
extern int Axis_DeSerialize_OutOfBoundStruct(OutOfBoundStruct* param, IWrapperSoapDeSerializer* pDZ);
extern void* Axis_Create_OutOfBoundStruct(OutOfBoundStruct *Obj, bool bArray = false, int nSize=0);
extern void Axis_Delete_OutOfBoundStruct(OutOfBoundStruct* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_OutOfBoundStruct(OutOfBoundStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
extern int Axis_GetSize_OutOfBoundStruct();
MathOpsWrapper::MathOpsWrapper()
{
pWs = new MathOps();
}
MathOpsWrapper::~MathOpsWrapper()
{
delete pWs;
}
/*implementation of WrapperClassHandler interface*/
void MathOpsWrapper::onFault(void *pMsg)
{
}
int MathOpsWrapper::init()
{
return AXIS_SUCCESS;
}
int MathOpsWrapper::fini()
{
return AXIS_SUCCESS;
}
/*
* This method invokes the right service method
*/
int MathOpsWrapper::invoke(void *pMsg)
{
IMessageData* mc = (IMessageData*)pMsg;
const AxisChar *method = mc->getOperationName();
if (0 == strcmp(method, "div"))
return div(mc);
else return AXIS_FAIL;
}
/*Methods corresponding to the web service methods*/
/*
* This method wrap the service method
*/
int MathOpsWrapper::div(void* pMsg)
{
IMessageData* mc = (IMessageData*)pMsg;
int nStatus;
IWrapperSoapSerializer* pIWSSZ = NULL;
mc->getSoapSerializer(&pIWSSZ);
if (!pIWSSZ) return AXIS_FAIL;
IWrapperSoapDeSerializer* pIWSDZ = NULL;
mc->getSoapDeSerializer(&pIWSDZ);
if (!pIWSDZ) return AXIS_FAIL;
/* check whether we have got correct message */
if (AXIS_SUCCESS != pIWSDZ->checkMessageBody("div", "http://soapinterop.org/wsdl")) return AXIS_FAIL;
pIWSSZ->createSoapMethod("divResponse", "http://soapinterop.org/wsdl");
int v0 = pIWSDZ->getElementAsInt("int0",0);
int v1 = pIWSDZ->getElementAsInt("int1",0);
if (AXIS_SUCCESS != (nStatus = pIWSDZ->getStatus())) return nStatus;
try
{
int ret = pWs->div(v0,v1);
return pIWSSZ->addOutputParam("divReturn", (void*)&ret, XSD_INT);
}
catch(AxisOutOfBoundException& e)
{
pIWSSZ->createSoapFault("OutOfBoundStruct", "http://soapinterop.org/wsdl");
OutOfBoundStruct* pObjFault = new OutOfBoundStruct();
/*User may write code here to fill the struct*/
SpecialDetailStruct* pObjSpecialDetailFault = new SpecialDetailStruct();
pObjSpecialDetailFault->varString = "This bound exception is a forced limitation";
if (pObjFault)
pObjFault->varString = "Value out of bound exception";
pObjFault->varInt = 2;
pObjFault->specialDetail = pObjSpecialDetailFault;
pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_OutOfBoundStruct,
(void*) Axis_Delete_OutOfBoundStruct,"OutOfBound", Axis_URI_OutOfBoundStruct);
throw;
}
catch(AxisDivByZeroException& e)
{
pIWSSZ->createSoapFault("DivByZeroStruct", "http://soapinterop.org/wsdl");
DivByZeroStruct* pObjFault = new DivByZeroStruct();
/*User may write code here to fill the struct*/
pObjFault->varString = "Division by zero exception";
pObjFault->varInt = 1;
pObjFault->varFloat = 10.52;
if (pObjFault)
pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_DivByZeroStruct,
(void*) Axis_Delete_DivByZeroStruct,"DivByZero", Axis_URI_DivByZeroStruct);
throw;
}
catch(AxisNormalDetailException& e)
{
pIWSSZ->createSoapFault("SpecialDetailStruct", "http://soapinterop.org/wsdl");
SpecialDetailStruct* pObjFault = new SpecialDetailStruct();
/*User may write code here to fill the struct*/
pObjFault->varString = "You have entered 1000 for the 1st paramter. 1000 is reserved. Please don't use it";
if (pObjFault)
pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_SpecialDetailStruct,
(void*) Axis_Delete_SpecialDetailStruct,"NormalDetail", Axis_URI_SpecialDetailStruct);
throw;
}
catch(...){
}
}
1.1 ws-axis/c/tests/server/exceptionTest/MathOpsWrapper.h
Index: MathOpsWrapper.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains Web Service Wrapper declarations
*/
#if !defined(__MATHOPSWRAPPER_SERVERWRAPPER_H__INCLUDED_)
#define __MATHOPSWRAPPER_SERVERWRAPPER_H__INCLUDED_
#include "MathOps.h"
#include <axis/server/WrapperClassHandler.h>
#include <axis/server/IMessageData.h>
#include <axis/server/GDefine.h>
#include <axis/server/AxisWrapperAPI.h>
#include "AxisOutOfBoundException.h"
#include "AxisDivByZeroException.h"
#include "AxisNormalDetailException.h"
class MathOpsWrapper : public WrapperClassHandler
{
private:/* Actual web service object*/
MathOps *pWs;
public:
MathOpsWrapper();
public:
virtual ~MathOpsWrapper();
public:/*implementation of WrapperClassHandler interface*/
int AXISCALL invoke(void* pMsg);
void AXISCALL onFault(void* pMsg);
int AXISCALL init();
int AXISCALL fini();
AXIS_BINDING_STYLE AXISCALL getBindingStyle(){return RPC_ENCODED;};
private:/*Methods corresponding to the web service methods*/
int div(void* pMsg);
};
#endif /* !defined(__MATHOPSWRAPPER_SERVERWRAPPER_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/OutOfBoundStruct.cpp
Index: OutOfBoundStruct.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type OutOfBoundStruct
*/
#include <malloc.h>
#include "OutOfBoundStruct.h"
#include <axis/server/AxisWrapperAPI.h>
extern int Axis_DeSerialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapDeSerializer* pDZ);
extern void* Axis_Create_SpecialDetailStruct(SpecialDetailStruct* pObj, bool bArray = false, int nSize=0);
extern void Axis_Delete_SpecialDetailStruct(SpecialDetailStruct* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
extern int Axis_GetSize_SpecialDetailStruct();
/*
* This static method serialize a OutOfBoundStruct type of object
*/
int Axis_Serialize_OutOfBoundStruct(OutOfBoundStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false)
{
if (bArray)
{
pSZ->serialize("<", Axis_TypeName_OutOfBoundStruct, ">", NULL);
}
else
{
const AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_OutOfBoundStruct);
pSZ->serialize("<", Axis_TypeName_OutOfBoundStruct, " xsi:type=\"", sPrefix, ":",
Axis_TypeName_OutOfBoundStruct, "\" xmlns:", sPrefix, "=\"",
Axis_URI_OutOfBoundStruct, "\">", NULL);
}
pSZ->serializeAsElement("varString", (void*)&(param->varString), XSD_STRING);
pSZ->serializeAsElement("varInt", (void*)&(param->varInt), XSD_INT);
Axis_Serialize_SpecialDetailStruct(param->specialDetail, pSZ);
pSZ->serialize("</", Axis_TypeName_OutOfBoundStruct, ">", NULL);
return AXIS_SUCCESS;
}
/*
* This static method deserialize a OutOfBoundStruct type of object
*/
int Axis_DeSerialize_OutOfBoundStruct(OutOfBoundStruct* param, IWrapperSoapDeSerializer* pIWSDZ)
{
param->varString = pIWSDZ->getElementAsString("varString",0);
param->varInt = pIWSDZ->getElementAsInt("varInt",0);
param->specialDetail = (SpecialDetailStruct*)pIWSDZ->getCmplxObject((void*)Axis_DeSerialize_SpecialDetailStruct
, (void*)Axis_Create_SpecialDetailStruct, (void*)Axis_Delete_SpecialDetailStruct
, "specialDetail", Axis_URI_SpecialDetailStruct);
return pIWSDZ->getStatus();
}
void* Axis_Create_OutOfBoundStruct(OutOfBoundStruct* pObj, bool bArray = false, int nSize=0)
{
if (bArray && (nSize > 0))
{
if (pObj)
{
OutOfBoundStruct* pNew = new OutOfBoundStruct[nSize];
memcpy(pNew, pObj, sizeof(OutOfBoundStruct)*nSize/2);
memset(pObj, 0, sizeof(OutOfBoundStruct)*nSize/2);
delete [] pObj;
return pNew;
}
else
{
return new OutOfBoundStruct[nSize];
}
}
else
return new OutOfBoundStruct;
}
/*
* This static method delete a OutOfBoundStruct type of object
*/
void Axis_Delete_OutOfBoundStruct(OutOfBoundStruct* param, bool bArray = false, int nSize=0)
{
if (bArray)
{
delete [] param;
}
else
{
delete param;
}
}
/*
* This static method gives the size of OutOfBoundStruct type of object
*/
int Axis_GetSize_OutOfBoundStruct()
{
return sizeof(OutOfBoundStruct);
}
OutOfBoundStruct::OutOfBoundStruct()
{
/*do not allocate memory to any pointer members here
because deserializer will allocate memory anyway. */
specialDetail=0;
}
OutOfBoundStruct::~OutOfBoundStruct()
{
/*delete any pointer and array members here*/
delete specialDetail;
}
1.1 ws-axis/c/tests/server/exceptionTest/OutOfBoundStruct.h
Index: OutOfBoundStruct.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type OutOfBoundStruct
*/
#if !defined(__OUTOFBOUNDSTRUCT_PARAM_H__INCLUDED_)
#define __OUTOFBOUNDSTRUCT_PARAM_H__INCLUDED_
#include <axis/server/AxisUserAPI.h>
#include "SpecialDetailStruct.h"
/*Local name and the URI for the type*/
static const char* Axis_URI_OutOfBoundStruct = "http://soapinterop.org/types";
static const char* Axis_TypeName_OutOfBoundStruct = "OutOfBoundStruct";
class SpecialDetailStruct;
class OutOfBoundStruct
{
public:
xsd__string varString;
int varInt;
SpecialDetailStruct* specialDetail;
OutOfBoundStruct();
virtual ~OutOfBoundStruct();
};
#endif /* !defined(__OUTOFBOUNDSTRUCT_PARAM_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/SpecialDetailStruct.cpp
Index: SpecialDetailStruct.cpp
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type SpecialDetailStruct
*/
#include <malloc.h>
#include "SpecialDetailStruct.h"
#include <axis/server/AxisWrapperAPI.h>
/*
* This static method serialize a SpecialDetailStruct type of object
*/
int Axis_Serialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapSerializer* pSZ, bool bArray = false)
{
if (bArray)
{
pSZ->serialize("<", Axis_TypeName_SpecialDetailStruct, ">", NULL);
}
else
{
const AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_SpecialDetailStruct);
pSZ->serialize("<", Axis_TypeName_SpecialDetailStruct, " xsi:type=\"", sPrefix, ":",
Axis_TypeName_SpecialDetailStruct, "\" xmlns:", sPrefix, "=\"",
Axis_URI_SpecialDetailStruct, "\">", NULL);
}
pSZ->serializeAsElement("varString", (void*)&(param->varString), XSD_STRING);
pSZ->serialize("</", Axis_TypeName_SpecialDetailStruct, ">", NULL);
return AXIS_SUCCESS;
}
/*
* This static method deserialize a SpecialDetailStruct type of object
*/
int Axis_DeSerialize_SpecialDetailStruct(SpecialDetailStruct* param, IWrapperSoapDeSerializer* pIWSDZ)
{
param->varString = pIWSDZ->getElementAsString("varString",0);
return pIWSDZ->getStatus();
}
void* Axis_Create_SpecialDetailStruct(SpecialDetailStruct* pObj, bool bArray = false, int nSize=0)
{
if (bArray && (nSize > 0))
{
if (pObj)
{
SpecialDetailStruct* pNew = new SpecialDetailStruct[nSize];
memcpy(pNew, pObj, sizeof(SpecialDetailStruct)*nSize/2);
memset(pObj, 0, sizeof(SpecialDetailStruct)*nSize/2);
delete [] pObj;
return pNew;
}
else
{
return new SpecialDetailStruct[nSize];
}
}
else
return new SpecialDetailStruct;
}
/*
* This static method delete a SpecialDetailStruct type of object
*/
void Axis_Delete_SpecialDetailStruct(SpecialDetailStruct* param, bool bArray = false, int nSize=0)
{
if (bArray)
{
delete [] param;
}
else
{
delete param;
}
}
/*
* This static method gives the size of SpecialDetailStruct type of object
*/
int Axis_GetSize_SpecialDetailStruct()
{
return sizeof(SpecialDetailStruct);
}
SpecialDetailStruct::SpecialDetailStruct()
{
/*do not allocate memory to any pointer members here
because deserializer will allocate memory anyway. */
}
SpecialDetailStruct::~SpecialDetailStruct()
{
/*delete any pointer and array members here*/
}
1.1 ws-axis/c/tests/server/exceptionTest/SpecialDetailStruct.h
Index: SpecialDetailStruct.h
===================================================================
/*
* This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
* This file contains functions to manipulate complex type SpecialDetailStruct
*/
#if !defined(__SPECIALDETAILSTRUCT_PARAM_H__INCLUDED_)
#define __SPECIALDETAILSTRUCT_PARAM_H__INCLUDED_
#include <axis/server/AxisUserAPI.h>
/*Local name and the URI for the type*/
static const char* Axis_URI_SpecialDetailStruct = "http://soapinterop.org/types";
static const char* Axis_TypeName_SpecialDetailStruct = "SpecialDetailStruct";
class SpecialDetailStruct
{
public:
xsd__string varString;
SpecialDetailStruct();
virtual ~SpecialDetailStruct();
};
#endif /* !defined(__SPECIALDETAILSTRUCT_PARAM_H__INCLUDED_)*/
1.1 ws-axis/c/tests/server/exceptionTest/deploy.wsdd
Index: deploy.wsdd
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:CPP="http://xml.apache.org/axis/wsdd/providers/CPP">
<service name="MathOpsService" provider="CPP:RPC" description="Axis C++ web service">
<parameter name="className" value="/user/local/apache/axis/MathOpsService.so"/>
<parameter name="allowedMethods" value="div "/>
</service>
</deployment>
1.1 ws-axis/c/tests/server/exceptionTest/undeploy.wsdd
Index: undeploy.wsdd
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<undeployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:CPP="http://xml.apache.org/axis/wsdd/providers/CPP">
<service name="MathOpsService"/>
</undeployment>