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/22 14:06:21 UTC
cvs commit: ws-axis/c/tests/client/exceptionTest AxisNormalDetailException.cpp AxisNormalDetailException.h AxisOutOfBoundException.cpp AxisOutOfBoundException.h OutOfBoundStruct.cpp OutOfBoundStruct.h SpecialDetailStruct.cpp SpecialDetailStruct.h AxisDivByZeroException.cpp AxisDivByZeroException.h DivByZeroStruct.cpp DivByZeroStruct.h Makefile.am MathOps.cpp MathOps.h MathOps.wsdl MathOpsClient.cpp
damitha 2004/06/22 05:06:20
Modified: c/tests/client/exceptionTest AxisDivByZeroException.cpp
AxisDivByZeroException.h DivByZeroStruct.cpp
DivByZeroStruct.h Makefile.am MathOps.cpp MathOps.h
MathOps.wsdl MathOpsClient.cpp
Added: c/tests/client/exceptionTest AxisNormalDetailException.cpp
AxisNormalDetailException.h
AxisOutOfBoundException.cpp
AxisOutOfBoundException.h OutOfBoundStruct.cpp
OutOfBoundStruct.h SpecialDetailStruct.cpp
SpecialDetailStruct.h
Log:
Revision Changes Path
1.3 +7 -22 ws-axis/c/tests/client/exceptionTest/AxisDivByZeroException.cpp
Index: AxisDivByZeroException.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/AxisDivByZeroException.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AxisDivByZeroException.cpp 14 Jun 2004 06:25:19 -0000 1.2
+++ AxisDivByZeroException.cpp 22 Jun 2004 12:06:20 -0000 1.3
@@ -1,21 +1,6 @@
/*
- * 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 Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
+ * 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"
@@ -68,11 +53,11 @@
{
/*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];
+ char* sMessage = new char[iSize];
+ m_sMessage = new char[iSize];
+ char* carrTempBuff =new char[4 * sizeof(char)];
sprintf(carrTempBuff, "%d", pFault->varInt);
- strcat(sMessage, carrTempBuff);
+ strcpy(sMessage, carrTempBuff);
strcat(sMessage, "\n");
sprintf(carrTempBuff, "%f", pFault->varFloat);
strcat(sMessage, carrTempBuff);
@@ -80,7 +65,7 @@
strcat(sMessage, pFault->varString);
strcat(sMessage, "\n");
m_sMessage = sMessage;
- free(sMessage);
+ delete(sMessage);
}
void AxisDivByZeroException::processException(exception* e)
1.3 +2 -17 ws-axis/c/tests/client/exceptionTest/AxisDivByZeroException.h
Index: AxisDivByZeroException.h
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/AxisDivByZeroException.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AxisDivByZeroException.h 14 Jun 2004 06:25:19 -0000 1.2
+++ AxisDivByZeroException.h 22 Jun 2004 12:06:20 -0000 1.3
@@ -1,21 +1,6 @@
/*
- * 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 Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
+ * 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_)
1.2 +3 -4 ws-axis/c/tests/client/exceptionTest/DivByZeroStruct.cpp
Index: DivByZeroStruct.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/DivByZeroStruct.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DivByZeroStruct.cpp 13 Jun 2004 14:26:48 -0000 1.1
+++ DivByZeroStruct.cpp 22 Jun 2004 12:06:20 -0000 1.2
@@ -1,7 +1,6 @@
/*
- *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 DivByZeroStruct
+ * 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>
@@ -36,7 +35,7 @@
/*
* This static method deserialize a DivByZeroStruct type of object
*/
-int Axis_DeSerialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapDeSerializer *pIWSDZ)
+int Axis_DeSerialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapDeSerializer* pIWSDZ)
{
param->varString = pIWSDZ->getElementAsString("varString",0);
param->varInt = pIWSDZ->getElementAsInt("varInt",0);
1.2 +2 -3 ws-axis/c/tests/client/exceptionTest/DivByZeroStruct.h
Index: DivByZeroStruct.h
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/DivByZeroStruct.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DivByZeroStruct.h 13 Jun 2004 14:26:48 -0000 1.1
+++ DivByZeroStruct.h 22 Jun 2004 12:06:20 -0000 1.2
@@ -1,7 +1,6 @@
/*
- *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 DivByZeroStruct
+ * 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_)
1.2 +2 -5 ws-axis/c/tests/client/exceptionTest/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.am 13 Jun 2004 14:26:48 -0000 1.1
+++ Makefile.am 22 Jun 2004 12:06:20 -0000 1.2
@@ -1,9 +1,6 @@
bin_PROGRAMS = mathops
SUBDIRS =
AM_CPPFLAGS = $(CPPFLAGS)
-mathops_SOURCES = MathOps.cpp \
- MathOpsClient.cpp \
- DivByZeroStruct.cpp \
- AxisDivByZeroException.cpp
-mathops_LDADD = $(LDFLAGS)
+mathops_SOURCES = OutOfBoundStruct.cpp AxisDivByZeroException.cpp AxisNormalDetailException.cpp MathOps.cpp SpecialDetailStruct.cpp AxisOutOfBoundException.cpp DivByZeroStruct.cpp MathOpsClient.cpp
+mathops_LDADD = $(LDFLAGS)
INCLUDES = -I$(AXISCPP_HOME)/include
1.3 +63 -40 ws-axis/c/tests/client/exceptionTest/MathOps.cpp
Index: MathOps.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/MathOps.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MathOps.cpp 14 Jun 2004 06:25:19 -0000 1.2
+++ MathOps.cpp 22 Jun 2004 12:06:20 -0000 1.3
@@ -1,21 +1,6 @@
/*
- * 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 Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
+ * 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"
@@ -24,24 +9,37 @@
using namespace std;
- bool CallBase::bInitialized;
-CallFunctions CallBase::ms_VFtable;
-extern int Axis_DeSerialize_DivByZeroStruct(DivByZeroStruct* param, IWrapperSoapDeSerializer *pDZ);
+ 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(const char* pchEndpointUri)
+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();
+
+MathOps::MathOps(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol)
+:Stub(pchEndpointUri, eProtocol)
+{
+}
+
+MathOps::MathOps()
+:Stub(" ", APTHTTP)
{
- m_pCall = new Call();
- m_pCall->setProtocol(APTHTTP);
- m_pCall->setEndpointURI(pchEndpointUri);
+ m_pCall->setEndpointURI("http://localhost/axis/MathOps");
}
MathOps::~MathOps()
{
- delete m_pCall;
}
@@ -64,6 +62,7 @@
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())
@@ -78,17 +77,34 @@
}
catch(AxisException& e)
{
- int iExceptionCode = e.getExceptionCode();
+ int iExceptionCode = e.getExceptionCode();
if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
- {
- throw;
- }
+ {
+ throw;
+ }
else 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(0 == strcmp("OutOfBoundStruct", cFaultstring))
+ {
+ if (AXIS_SUCCESS == m_pCall->checkFault("faultdetail","http://localhost/axis/MathOps"))
+ {
+ OutOfBoundStruct* pFaultDetail = NULL;
+ pFaultDetail = (OutOfBoundStruct*)m_pCall->
+ getCmplxObject((void*) Axis_DeSerialize_OutOfBoundStruct,
+ (void*) Axis_Create_OutOfBoundStruct,
+ (void*) Axis_Delete_OutOfBoundStruct,"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 AxisOutOfBoundException(pFaultDetail);
+ }
+ }
+ else if(0 == strcmp("DivByZeroStruct", cFaultstring))
{
if (AXIS_SUCCESS == m_pCall->checkFault("faultdetail","http://localhost/axis/MathOps"))
{
@@ -98,8 +114,6 @@
(void*) Axis_Create_DivByZeroStruct,
(void*) Axis_Delete_DivByZeroStruct,"faultstruct1", 0);
/*User code to handle the struct can be inserted here*/
- char* temp = pFaultDetail->varString;
- printf("%s\n", temp);
printf("faultcode:%s\n", cFaultcode);
printf("faultstring:%s\n", cFaultstring);
printf("faultactor:%s\n", cFaultactor);
@@ -107,6 +121,23 @@
throw AxisDivByZeroException(pFaultDetail);
}
}
+ else if(0 == strcmp("SpecialDetailStruct", cFaultstring))
+ {
+ if (AXIS_SUCCESS == m_pCall->checkFault("faultdetail","http://localhost/axis/MathOps"))
+ {
+ SpecialDetailStruct* pFaultDetail = NULL;
+ pFaultDetail = (SpecialDetailStruct*)m_pCall->
+ getCmplxObject((void*) Axis_DeSerialize_SpecialDetailStruct,
+ (void*) Axis_Create_SpecialDetailStruct,
+ (void*) Axis_Delete_SpecialDetailStruct,"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 AxisNormalDetailException(pFaultDetail);
+ }
+ }
else
{
cFaultdetail = m_pCall->getElementAsString("faultdetail", 0);
@@ -115,14 +146,6 @@
}
else throw;
}
-}
-
-int MathOps::getStatus()
-{
- if ( m_pCall==NULL )
- return AXIS_SUCCESS;
- else
- return m_pCall->getStatus();
}
int MathOps::getFaultDetail(char** ppcDetail)
1.6 +11 -164 ws-axis/c/tests/client/exceptionTest/MathOps.h
Index: MathOps.h
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/MathOps.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MathOps.h 14 Jun 2004 07:21:31 -0000 1.5
+++ MathOps.h 22 Jun 2004 12:06:20 -0000 1.6
@@ -1,183 +1,30 @@
/*
- * 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 Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- *
+ * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)
+ * This file contains Client Stub Class for remote web service
*/
#if !defined(__MATHOPS_CLIENTSTUB_H__INCLUDED_)
#define __MATHOPS_CLIENTSTUB_H__INCLUDED_
-#include <axis/client/Call.h>
+#include <axis/client/Stub.h>
/*include Exception header files here*/
-#include "AxisDivByZeroException.h"
#include "DivByZeroStruct.h"
+#include "SpecialDetailStruct.h"
+#include "OutOfBoundStruct.h"
+#include "AxisOutOfBoundException.h"
+#include "AxisDivByZeroException.h"
+#include "AxisNormalDetailException.h"
-/**
- * @class MathOps.h
- * @brief A test class for exception and fault mapping.
- *
- * This class is used to demonstrate error handling and fault mapping
- * testing. Here I have generated the stuff using MathOps.wsdl. This wsdl
- * simply have a complex type which consists of three simple types(xsd:int,
- * xsd:foat and xsd:string). For portType operation "div" we have a fault named
- * DivByZero the message for which is DivByZeroFault which is of the complex
- * type mentioned above(DivByZeroStruct). The server side for this client
- * sample is in $AXISCPP_HOME/samples/server/rpcfault.
- * When you generated the client side it will generate header and
- * implementation files for three different types, namely,
- * MathOps: Service request class which calls div service method in the server
- * and getFaultDetails if there's any.
- * DivByZeroStruct: The type corresponding to the complex type DivByZeroStruct
- * in the MathOps.wsdl
- * AxisDivByZeroException: For each fault in wsdl we generate an exception
- * class which is derived from AxisException base class which is the root
- * class for exceptions in Axis C++. This root class in tern is derived
- * from std::exception.
- * In the server side if division by zero fault is encountered
- * in the service method it will call
- * ...
- * ...
- * pIWSSZ->createSoapFault("DivByZeroStruct", "http://soapinterop.org/wsdl");
- * ...
- * ...
- * where pIWSSZ is the soap serializer interface.
- * Once this method is called
- * m_pSoapEnvelope->m_pSoapBody->m_pSoapFault is assigned a new soap fault
- * object. After that,
- *
- * DivByZeroStruct* pObjFault = new DivByZeroStruct();
- * 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);
- *
- * Here the service developer fills the DivByZeroStruct with appropriate
- * values and call SoapSerialzer's addFaultDetail method with the knowledge
- * of serializing and deserializing. Once this method is called setFaultDetail
- * method of SoapFault is called from SoapSerializer.
- * ...
- * ...
- * int SoapFault::setFaultDetail(const Param* pFaultDetail)
- * {
- * m_pFaultDetail = (Param*) pFaultDetail;
- * return AXIS_SUCCESS;
- * }
- * ...
- * ...
- *
- * So once the serialize method of SoapSerializer is called then in addition to
- * serializing Faultcode, Faultstring and Faultactor, SoapFault's FaultDetail
- * object is also serialized into the soap body's fault detail tag.
- * So in the wire comes the Soap message with a soap fault.
- *
- * Now when you run the client here, if it catch an exception
- * ...
- * ...
- * catch(AxisException& e)
- * {
- * int iExceptionCode = e.getExceptionCode();
- * if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
- * {
- * throw;
- * }
- * ...
- * ...
- * it checks the exception code and if exception code is not equal to
- * AXISC_NODE_VALUE_MISMATCH_EXCEPTION value it means that the exception
- * thrown not because of a soap fault. Exception is caused by some other
- * mean in the client side. If a soap fault comes in the wire SoapDeseriazer's
- * checkMessageBody method throws and exception
- * ...
- * ...
- * throw AxisException(AXISC_NODE_VALUE_MISMATCH_EXCEPTION);
- * ...
- * ...
- *
- * When we catch that exception we knows that a soap fault has come.
- * ...
- * ...
- * else 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);
- * //Client developers code goes here to handle the struct can
- * //be inserted here
- * char* temp = pFaultDetail->varString;
- * printf("%s\n", temp);
- * printf("faultcode:%s\n", cFaultcode);
- * printf("faultstring:%s\n", cFaultstring);
- * printf("faultactor:%s\n", cFaultactor);
- * m_pCall->unInitialize();
- * throw AxisDivByZeroException(pFaultDetail);
- * }
- * }
- * ...
- * ...
- * Note that we compares cFaultstring which contains soap fault's faultstring
- * with the DivByZeroStruct. This is so because in the server side we set the
- * faultstring to take the fault's generated type name. If the faultdetail
- * is just a simple string
- * ...
- * ...
- * else
- * {
- * cFaultdetail = m_pCall->getElementAsString("faultdetail", 0);
- * throw AxisException(cFaultdetail);
- * }
- * ...
- * ...
- *
- * You can also use this class as a test utility to test exceptions. You
- * can generate exception in the server side and client side and test
- * from here whether the correct exception messages come to the client.
- * For example you can remove the shared libraries for MathOps service
- * (libmathops.so) from $AXIS_HOME/webservices folder and try to run
- * client here. The you will get an exception message like "Service library
- * is not loaded to the engine".
- *
- * @author Damitha Kumarage (damitha@opensource.lk, damitha@jkcsworld.com)
- */
-class MathOps
+class MathOps :public Stub
{
-private:
- Call* m_pCall;
public:
- MathOps(const char* pchEndpointUri);
+ MathOps(const char* pchEndpointUri, AXIS_PROTOCOL_TYPE eProtocol=APTHTTP);
+ MathOps();
public:
virtual ~MathOps();
public:
int div(int Value0,int Value1);
- int getStatus();
int getFaultDetail(char** ppcDetail);
};
1.2 +26 -0 ws-axis/c/tests/client/exceptionTest/MathOps.wsdl
Index: MathOps.wsdl
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/MathOps.wsdl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MathOps.wsdl 14 Jun 2004 03:36:08 -0000 1.1
+++ MathOps.wsdl 22 Jun 2004 12:06:20 -0000 1.2
@@ -9,11 +9,29 @@
<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"/>
@@ -26,6 +44,8 @@
<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">
@@ -46,6 +66,12 @@
<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">
1.2 +9 -1 ws-axis/c/tests/client/exceptionTest/MathOpsClient.cpp
Index: MathOpsClient.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/tests/client/exceptionTest/MathOpsClient.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MathOpsClient.cpp 13 Jun 2004 14:26:48 -0000 1.1
+++ MathOpsClient.cpp 22 Jun 2004 12:06:20 -0000 1.2
@@ -59,6 +59,14 @@
{
printf("Exception : %s\n", e.what());
}
+ catch(AxisOutOfBoundException& e)
+ {
+ printf("Exception : %s\n", e.what());
+ }
+ catch(AxisNormalDetailException& e)
+ {
+ printf("Exception : %s\n", e.what());
+ }
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
@@ -86,7 +94,7 @@
bool IsNumber(const char* p)
{
- for (int x=0; x < strlen(p); x++)
+ for (int x=1; x < strlen(p); x++)
{
if (!isdigit(p[x])) return false;
}
1.1 ws-axis/c/tests/client/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*/
int iSize = strlen(pFault->varString) + 8;
char* sMessage = new char[iSize];
m_sMessage = new char[iSize];
strcpy(sMessage, pFault->varString);
strcat(sMessage, "\n");
m_sMessage = sMessage;
delete(sMessage);
}
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/client/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/client/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*/
int iSize = strlen(pFault->varString) + 8;
char* sMessage = new char[iSize];
m_sMessage = new char[iSize];
char* carrTempBuff =new char[4 * sizeof(char)];
strcpy(sMessage, pFault->varString);
strcat(sMessage, "\n");
sprintf(carrTempBuff, "%d", pFault->varInt);
strcat(sMessage, carrTempBuff);
strcat(sMessage, "\n");
SpecialDetailStruct* pFaultDetail = pFault->specialDetail;
strcat(sMessage, pFaultDetail->varString);
m_sMessage = sMessage;
delete(sMessage);
}
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/client/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/client/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/client/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/client/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/client/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_)*/