/*
 * 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(OutOfBoundStruct* pObjFault)
	{
		if (pObjFault)
                {
		        pIWSSZ->createSoapFault("OutOfBoundStruct", "http://soapinterop.org/wsdl",
			"AxisC++ Faultcode", "Custom Out of bound exception");
			pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_OutOfBoundStruct,
			(void*) Axis_Delete_OutOfBoundStruct,"OutOfBoundStruct", Axis_URI_OutOfBoundStruct);
		        throw AxisServiceException();
                 }
	}

	catch(DivByZeroStruct* pObjFault)
	{
		if (pObjFault)
                {
		        pIWSSZ->createSoapFault("DivByZeroStruct", "http://soapinterop.org/wsdl",
			"AxisC++ Faultcode", "Division by zero exception");
			pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_DivByZeroStruct,
			(void*) Axis_Delete_DivByZeroStruct,"DivByZeroStruct", Axis_URI_DivByZeroStruct);
                        throw AxisServiceException();
                }
	}

	catch(SpecialDetailStruct* pObjFault)
	{
		if (pObjFault)
                {
		        pIWSSZ->createSoapFault("SpecialDetailStruct", "http://soapinterop.org/wsdl",
			"AxisC++ Faultcode", "Custom constrain");
			pIWSSZ->addFaultDetail(pObjFault, (void*) Axis_Serialize_SpecialDetailStruct,
			(void*) Axis_Delete_SpecialDetailStruct,"SpecialDetailStruct", Axis_URI_SpecialDetailStruct);
                        throw AxisServiceException();
                }
	}

	catch(...){
	}
}

