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/05/27 13:12:27 UTC
cvs commit: ws-axis/c/samples/client/doclitfault AxisDivByZeroException.cpp AxisDivByZeroException.h DivByZeroFault.cpp DivByZeroFault.h MathOps.cpp MathOps.h
damitha 2004/05/27 04:12:27
Added: c/samples/client/doclitfault AxisDivByZeroException.cpp
AxisDivByZeroException.h DivByZeroFault.cpp
DivByZeroFault.h MathOps.cpp MathOps.h
Log:
Revision Changes Path
1.1 ws-axis/c/samples/client/doclitfault/AxisDivByZeroException.cpp
Index: AxisDivByZeroException.cpp
===================================================================
/* -*- 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
*
*/
#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.
*/
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(DivByZeroFault* 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 (DivByZeroFault* pFault)
{
/*start user code*/
int iSize = strlen(pFault->varString) + 8;
char* sMessage = (char*) malloc(iSize);
m_sMessage = (char*) malloc(iSize);
char carrTempBuff[4];
sprintf(carrTempBuff, "%d", pFault->varInt);
strcat(sMessage, carrTempBuff);
strcat(sMessage, "\n");
sprintf(carrTempBuff, "%f", pFault->varFloat);
strcat(sMessage, carrTempBuff);
strcat(sMessage, "\n");
strcat(sMessage, pFault->varString);
strcat(sMessage, "\n");
m_sMessage = sMessage;
free(sMessage);
/*end user code*/
}
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/samples/client/doclitfault/AxisDivByZeroException.h
Index: AxisDivByZeroException.h
===================================================================
/*
* 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
*
*/
#ifndef __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
#define __AXISDIVBYZEROEXCEPTION_H_OF_AXIS_INCLUDED_
#include <string>
#include <exception>
#include <axis/server/AxisException.h>
#include "DivByZeroFault.h"
using namespace std;
class AxisDivByZeroException : public AxisException
{
public:
AxisDivByZeroException();
AxisDivByZeroException(DivByZeroFault* 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(DivByZeroFault* pFault);
void processException(exception* e, int iExceptionCode);
void processException(int iExceptionCode);
string m_sMessage;
int m_iExceptionCode;
};
#endif
1.1 ws-axis/c/samples/client/doclitfault/DivByZeroFault.cpp
Index: DivByZeroFault.cpp
===================================================================
/*
*This file is automatically generated by the Axis C++ Wrapper Class Generator
*Web service wrapper class's implementation generated by Axis WCG
*Parameters and wrapper methos to manipulate DivByZeroFault
*/
#include <malloc.h>
#include "DivByZeroFault.h"
#include <axis/server/AxisWrapperAPI.h>
/*
* This static method serialize a DivByZeroFault type of object
*/
int Axis_Serialize_DivByZeroFault(DivByZeroFault* param, IWrapperSoapSerializer* pSZ, bool bArray = false)
{
if (bArray)
{
pSZ->serialize("<", Axis_TypeName_DivByZeroFault, ">", NULL);
}
else
{
const AxisChar* sPrefix = pSZ->getNamespacePrefix(Axis_URI_DivByZeroFault);
pSZ->serialize("<", Axis_TypeName_DivByZeroFault, " xsi:type=\"", sPrefix, ":",
Axis_TypeName_DivByZeroFault, "\" xmlns:", sPrefix, "=\"",
Axis_URI_DivByZeroFault, "\">", 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_DivByZeroFault, ">", NULL);
return AXIS_SUCCESS;
}
/*
* This static method deserialize a DivByZeroFault type of object
*/
int Axis_DeSerialize_DivByZeroFault(DivByZeroFault* 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_DivByZeroFault(DivByZeroFault* pObj, bool bArray = false, int nSize=0)
{
if (bArray && (nSize > 0))
{
if (pObj)
{
DivByZeroFault* pNew = new DivByZeroFault[nSize];
memcpy(pNew, pObj, sizeof(DivByZeroFault)*nSize/2);
memset(pObj, 0, sizeof(DivByZeroFault)*nSize/2);
delete [] pObj;
return pNew;
}
else
{
return new DivByZeroFault[nSize];
}
}
else
return new DivByZeroFault;
}
/*
* This static method delete a DivByZeroFault type of object
*/
void Axis_Delete_DivByZeroFault(DivByZeroFault* param, bool bArray = false, int nSize=0)
{
if (bArray)
{
delete [] param;
}
else
{
delete param;
}
}
/*
* This static method gives the size of DivByZeroFault type of object
*/
int Axis_GetSize_DivByZeroFault()
{
return sizeof(DivByZeroFault);
}
DivByZeroFault::DivByZeroFault()
{
/*do not allocate memory to any pointer members here
because deserializer will allocate memory anyway. */
}
DivByZeroFault::~DivByZeroFault()
{
/*delete any pointer and array members here*/
}
1.1 ws-axis/c/samples/client/doclitfault/DivByZeroFault.h
Index: DivByZeroFault.h
===================================================================
/*
*This file is automatically generated by the Axis C++ Wrapper Class Generator
*Web service wrapper class's implementation generated by Axis WCG
*Parameters and wrapper methos to manipulate DivByZeroFault
*/
#if !defined(__DIVBYZEROFAULT_PARAM_H__INCLUDED_)
#define __DIVBYZEROFAULT_PARAM_H__INCLUDED_
#include <axis/server/AxisUserAPI.h>
/*Local name and the URI for the type*/
static const char* Axis_URI_DivByZeroFault = "http://localhost/axis/MathOps/types";
static const char* Axis_TypeName_DivByZeroFault = "DivByZeroFault";
class DivByZeroFault
{
public:
xsd__string varString;
int varInt;
float varFloat;
DivByZeroFault();
~DivByZeroFault();
void setFaultcode();
void setFaultstring();
void setFaultDetail();
};
#endif /* !defined(__DIVBYZEROFAULT_PARAM_H__INCLUDED_)*/
1.1 ws-axis/c/samples/client/doclitfault/MathOps.cpp
Index: MathOps.cpp
===================================================================
/*
* This is the Client Stub implementation file genarated by WSDL2Ws tool.
* MathOps.cpp: implemtation for the MathOps.
*
*/
#include "MathOps.h"
#include <axis/server/AxisWrapperAPI.h>
bool CallBase::bInitialized;
CallFunctions CallBase::ms_VFtable;
extern int Axis_DeSerialize_DivByZeroFault(DivByZeroFault* param, IWrapperSoapDeSerializer *pDZ);
extern void* Axis_Create_DivByZeroFault(DivByZeroFault *Obj, bool bArray = false, int nSize=0);
extern void Axis_Delete_DivByZeroFault(DivByZeroFault* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_DivByZeroFault(DivByZeroFault* param, IWrapperSoapSerializer* pSZ, bool bArray = false);
extern int Axis_GetSize_DivByZeroFault();
MathOps::MathOps()
{
m_pCall = new Call();
m_pCall->setProtocol(APTHTTP);
m_pCall->setEndpointURI("http://localhost/axis/MathOpsPort");
}
MathOps::~MathOps()
{
delete m_pCall;
}
/*Methods corresponding to the web service methods*/
/*
* This method wrap the service methoddiv
*/
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://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);
}
}
}
catch(AxisException& e)
{
if(AXIS_SUCCESS == m_pCall->checkFault("Fault",
"http://localhost/axis/MathOps/types")) //Exception handling code goes here
{
cFaultcode = m_pCall->getElementAsString("faultcode", 0);
cFaultstring = m_pCall->getElementAsString("faultstring", 0);
cFaultactor = m_pCall->getElementAsString("faultactor", 0);
if(AXIS_SUCCESS == m_pCall->checkFault("faultdetail",
"http://localhost/axis/MathOps/types"))
{
m_pCall->getFaultDetail(&cFaultdetail);
throw AxisException(cFaultdetail);
}
else
{
DivByZeroFault* pFaultDetail = NULL;
pFaultDetail = (DivByZeroFault*)m_pCall->
getCmplxObject((void*) Axis_DeSerialize_DivByZeroFault,
(void*) Axis_Create_DivByZeroFault,
(void*) Axis_Delete_DivByZeroFault,"faultstruct", 0);
char* temp = pFaultDetail->varString;
printf("%s\n", temp);
/*start user code*/
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 throw;
}
m_pCall->unInitialize();
return Ret;
}
int MathOps::getFaultDetail(char** ppcDetail)
{
m_pCall->getFaultDetail(ppcDetail);
}
//int MathOps::getStatus(){if ( m_pCall==NULL ) return AXIS_SUCCESS; else return m_pCall->getStatus();}
1.1 ws-axis/c/samples/client/doclitfault/MathOps.h
Index: MathOps.h
===================================================================
/*
* This is the Client Stub Class genarated by the tool WSDL2Ws
* MathOps.h: interface for the MathOpsclass.
*
*/
#if !defined(__MATHOPS_CLIENTSTUB_H__INCLUDED_)
#define __MATHOPS_CLIENTSTUB_H__INCLUDED_
#include <axis/client/Call.h>
#include "DivByZeroFault.h"
#include "AxisDivByZeroException.h"
class MathOps
{
private:
Call* m_pCall;
public:
MathOps();
public:
virtual ~MathOps();
public:
int div(int Value0,int Value1);
int getFaultDetail(char** ppcDetail);
//int getStatus();
};
#endif /* !defined(__MATHOPS_CLIENTSTUB_H__INCLUDED_)*/