/*
 * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
 * This file contains Client Stub implementation for remote web service.
 */

#include "MathOps.h"

#include <axis/server/AxisWrapperAPI.h>

using namespace std;

 MathOps::MathOps(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
:Stub(pchEndpointUri, eProtocol)
{
}

MathOps::MathOps()
:Stub(" ", APTHTTP)
{
	m_pCall->setEndpointURI("http://localhost/axis/MathOps");
}

MathOps::~MathOps()
{
}


/*Methods corresponding to the web service methods*/

/*
 * This method wrap the service method div
 */
int MathOps::div(int Value0, int Value1)
{
	int Ret;
	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");
		applyUserPreferences();
		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)
	{
		int iExceptionCode = e.getExceptionCode();
		if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
		{
		        m_pCall->unInitialize();
			throw;
		}
                ISoapFault* pSoapFault = (ISoapFault*) m_pCall->checkFault("Fault",
		    "http://localhost/axis/MathOps");
                if(pSoapFault)
                {
		    m_pCall->unInitialize();
                    throw AxisClientException(pSoapFault);
		}
		else throw;
	}
}

int MathOps::getFaultDetail(char** ppcDetail)
{
	return m_pCall->getFaultDetail(ppcDetail);
}

