whitlock 2005/02/15 02:54:56
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws
SourceWriterFactory.java WSDL2Ws.java
WebServiceGeneratorImpl.java
c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal
ClientStubHeaderWriter.java ClientStubWriter.java
ParmHeaderFileWriter.java
c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info Type.java
c/tests/auto_build/testcases/client/cpp
FaultMappingDocClient.cpp
c/tests/auto_build/testcases/output FaultMappingDoc.cpp.out
Added: c/include/axis SoapFaultException.hpp
c/src/soap SoapFaultException.cpp
Log:
For user-defined soap faults, throw the complex type that represents the
fault and make SoapFaultException the superclass of all user-defined soap
faults. This will simplify client applications as it simplifies the memory
model.
Revision Changes Path
1.15 +0 -5
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/SourceWriterFactory.java
Index: SourceWriterFactory.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/SourceWriterFactory.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SourceWriterFactory.java 11 Nov 2004 13:29:10 -0000 1.14
+++ SourceWriterFactory.java 15 Feb 2005 10:54:55 -0000 1.15
@@ -56,8 +56,6 @@
return new
org.apache.axis.wsdl.wsdl2ws.cpp.ClientStubHeaderWriter(wscontext);
case WrapperConstants.GENERATOR_CLIENT_STUB_CPP :
return new
org.apache.axis.wsdl.wsdl2ws.cpp.ClientStubWriter(wscontext);
- case WrapperConstants.GENERATOR_CLIENT_EXCEPTION :
- return new
org.apache.axis.wsdl.wsdl2ws.cpp.AllExceptionWriter(wscontext, "Client");
case WrapperConstants.GENERATOR_SERVER_EXCEPTION :
return new
org.apache.axis.wsdl.wsdl2ws.cpp.AllExceptionWriter(wscontext, "Server");
//C
@@ -99,9 +97,6 @@
return new
org.apache.axis.wsdl.wsdl2ws.cpp.literal.ClientStubHeaderWriter(wscontext);
case WrapperConstants.GENERATOR_CLIENT_STUB_CPP :
return new
org.apache.axis.wsdl.wsdl2ws.cpp.literal.ClientStubWriter(wscontext);
- case WrapperConstants.GENERATOR_CLIENT_EXCEPTION :
- // nithya
- return new
org.apache.axis.wsdl.wsdl2ws.cpp.AllExceptionWriter(wscontext, "Client");
case WrapperConstants.GENERATOR_SERVER_EXCEPTION :
// nithya
return new
org.apache.axis.wsdl.wsdl2ws.cpp.AllExceptionWriter(wscontext, "Server");
1.55 +3 -1
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java
Index: WSDL2Ws.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WSDL2Ws.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- WSDL2Ws.java 10 Feb 2005 18:14:15 -0000 1.54
+++ WSDL2Ws.java 15 Feb 2005 10:54:55 -0000 1.55
@@ -1034,7 +1034,9 @@
while (partIt.hasNext())
{
- faultinfo.addParam(createParameterInfo((Part)
partIt.next()));
+ ParameterInfo pinfo = createParameterInfo((Part)
partIt.next());
+ pinfo.getType().setAsFault(true);
+ faultinfo.addParam(pinfo);
}
//add by nithya
methodinfo.addFaultType(faultinfo);
1.4 +0 -3
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WebServiceGeneratorImpl.java
Index: WebServiceGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/WebServiceGeneratorImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebServiceGeneratorImpl.java 11 Nov 2004 10:14:40 -0000 1.3
+++ WebServiceGeneratorImpl.java 15 Feb 2005 10:54:55 -0000 1.4
@@ -92,9 +92,6 @@
(new
Generator(WrapperConstants.GENERATOR_CLIENT_STUB_HPP,
wscontext))
.generate();
- (new
Generator(WrapperConstants.GENERATOR_CLIENT_EXCEPTION,
- wscontext))
- .generate();
}
// Generate objects common to Client and Server
(new Generator(WrapperConstants.GENERATOR_PARAM_CPP_ALL,
1.30 +2 -6
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java
Index: ClientStubHeaderWriter.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubHeaderWriter.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ClientStubHeaderWriter.java 17 Dec 2004 11:49:46 -0000 1.29
+++ ClientStubHeaderWriter.java 15 Feb 2005 10:54:55 -0000 1.30
@@ -160,13 +160,9 @@
try
{
writer.write("#include <axis/client/Stub.hpp>\n");
+ writer.write("#include <axis/SoapFaultException.hpp>\n");
writer.write("#include <axis/ISoapFault.hpp>\n");
- writer.write(
- "#include \""
- + wscontext.getSerInfo().getServicename()
- + "_AxisClientException"
- + CUtils.CPP_HEADER_SUFFIX
- + "\"\n");
+ writer.write("AXIS_CPP_NAMESPACE_USE\n");
Type atype;
Iterator types =
this.wscontext.getTypemap().getTypes().iterator();
HashSet typeSet = new HashSet();
1.64 +28 -38
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java
Index: ClientStubWriter.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ClientStubWriter.java,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- ClientStubWriter.java 11 Feb 2005 11:36:30 -0000 1.63
+++ ClientStubWriter.java 15 Feb 2005 10:54:55 -0000 1.64
@@ -926,13 +926,12 @@
writer.write(
"\t\tif(AXISC_NODE_VALUE_MISMATCH_EXCEPTION !=
iExceptionCode)\n");
writer.write("\t\t{\n");
- writer.write(
- "\t\t\tthrow "
- + wscontext.getSerInfo().getServicename()
- + "_AxisClientException(e.what());\n");
+ writer.write("\t\t\tm_pCall->unInitialize();\n");
+ writer.write("\t\t\tthrow SoapFaultException(e);\n");
writer.write("\t\t}\n");
writer.write(
- "\t\tISoapFault* pSoapFault = (ISoapFault*)
m_pCall->checkFault(\"Fault\",\""
+ "\t\tISoapFault* pSoapFault = (ISoapFault*)\n");
+ writer.write("\t\t\tm_pCall->checkFault(\"Fault\",\""
+ wscontext.getWrapInfo().getTargetEndpointURI()
+ "\" );\n");
writer.write("\t\tif(pSoapFault)\n");
@@ -948,12 +947,8 @@
int j = 0;
if (!paramsFault.hasNext())
{
- writer.write("\tm_pCall->unInitialize();\n");
- //writer.write("\t\t\tm_pCall->unInitialize();\n");
- writer.write(
- "\t\t\tthrow "
- + wscontext.getSerInfo().getServicename()
- + "_AxisClientException(pSoapFault);\n");
+ writer.write("\t\t\tm_pCall->unInitialize();\n");
+ writer.write("\t\t\tthrow SoapFaultException(e);\n");
}
else
{
@@ -1023,13 +1018,10 @@
}
if (flag == true)
{
- writer.write("\t\t\telse\n\t\t\t{\n");
- writer.write("\tm_pCall->unInitialize();\n");
- //writer.write("\t\t\t\t m_pCall->unInitialize();\n");
- writer.write(
- "\t\t\t\t throw "
- + wscontext.getSerInfo().getServicename()
- + "_AxisClientException(pSoapFault);\n");
+ writer.write("\t\t\telse\n");
+ writer.write("\t\t\t{\n");
+ writer.write("\t\t\t\tm_pCall->unInitialize();\n");
+ writer.write("\t\t\t\tthrow SoapFaultException(e);\n");
writer.write("\t\t\t}\n");
}
writer.write("\t\t}\n");
@@ -1050,28 +1042,26 @@
writer.write(
"(0 == strcmp(\"" + faultInfoName + "\",
pcCmplxFaultName))\n");
writer.write("\t\t\t{\n");
- writer.write("\t\t\t\t" + faulttype + " pFaultDetail = NULL;\n");
+ writer.write("\t\t\t\t" + faulttype + " pFaultDetail = \n");
+ writer.write(
+ "\t\t\t\t\t(" + faulttype +
")pSoapFault->getCmplxFaultObject(\n");
+ writer.write(
+ "\t\t\t\t\t\t(void*) Axis_DeSerialize_" + langName + ",\n");
+ writer.write("\t\t\t\t\t\t(void*) Axis_Create_" + langName +
",\n");
+ writer.write("\t\t\t\t\t\t(void*) Axis_Delete_" + langName +
",\n");
+ writer.write("\t\t\t\t\t\t\"" + faultInfoName + "\",\n");
+ writer.write("\t\t\t\t\t\t0);\n\n");
+ writer.write(
+
"\t\t\t\tpFaultDetail->setFaultCode(pSoapFault->getFaultcode().c_str());\n");
+ writer.write(
+
"\t\t\t\tpFaultDetail->setFaultString(pSoapFault->getFaultstring().c_str());\n");
+ writer.write(
+
"\t\t\t\tpFaultDetail->setFaultActor(pSoapFault->getFaultactor().c_str());\n");
writer.write(
- "\t\t\t\tpFaultDetail = (" + faulttype + ")pSoapFault->\n");
+
"\t\t\t\tpFaultDetail->setExceptionCode(e.getExceptionCode());\n");
+ writer.write("\t\t\t\tm_pCall->unInitialize();\n");
writer.write(
- "\t\t\t\t\tgetCmplxFaultObject((void*) Axis_DeSerialize_"
- + langName
- + ",\n");
- writer.write("\t\t\t\t\t(void*) Axis_Create_" + langName +
",\n");
- writer.write(
- "\t\t\t\t\t(void*) Axis_Delete_"
- + langName
- + ",\""
- + faultInfoName
- + "\", 0);\n");
- writer.write(
- "\t\t\t\tpSoapFault->setCmplxFaultObject(pFaultDetail);\n");
- writer.write("\tm_pCall->unInitialize();\n");
- //writer.write("\t\t\t\tm_pCall->unInitialize();\n");
- writer.write(
- "\t\t\t\tthrow "
- + wscontext.getSerInfo().getServicename()
- + "_AxisClientException(pSoapFault);\n");
+ "\t\t\t\tthrow *pFaultDetail;\n");
writer.write("\t\t\t}\n");
}
catch (IOException e)
1.30 +6 -1
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ParmHeaderFileWriter.java
Index: ParmHeaderFileWriter.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/literal/ParmHeaderFileWriter.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ParmHeaderFileWriter.java 23 Nov 2004 17:21:07 -0000 1.29
+++ ParmHeaderFileWriter.java 15 Feb 2005 10:54:55 -0000 1.30
@@ -74,7 +74,10 @@
else
{
writePreprocessorStatements();
- this.writer.write("class STORAGE_CLASS_INFO " + classname +
"\n{\n");
+ this.writer.write("class STORAGE_CLASS_INFO " + classname);
+ if (this.type.isFault())
+ this.writer.write(" : public SoapFaultException");
+ this.writer.write("\n{\n");
writeAttributes();
writeConstructors();
writeDestructors();
@@ -398,6 +401,8 @@
try
{
writer.write("#include <axis/AxisUserAPI.hpp>\n");
+ if (this.type.isFault())
+ writer.write("#include <axis/SoapFaultException.hpp>\n");
writer.write("AXIS_CPP_NAMESPACE_USE \n\n");
HashSet typeSet = new HashSet();
for (int i = 0; i < attribs.length; i++)
1.24 +12 -0
ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java
Index: Type.java
===================================================================
RCS file:
/home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Type.java 28 Oct 2004 14:14:54 -0000 1.23
+++ Type.java 15 Feb 2005 10:54:55 -0000 1.24
@@ -86,6 +86,9 @@
private String language;
//Samisa: element type
private String elementType;
+
+ /* is this type going to be thrown as a soap fault? */
+ private boolean isFault = false;
public Type(
QName name,
@@ -569,4 +572,13 @@
this.extensionBaseType = extensionBaseType;
}
+ public void setAsFault(boolean isFault)
+ {
+ this.isFault = isFault;
+ }
+
+ public boolean isFault()
+ {
+ return isFault;
+ }
}
1.12 +30 -19
ws-axis/c/tests/auto_build/testcases/client/cpp/FaultMappingDocClient.cpp
Index: FaultMappingDocClient.cpp
===================================================================
RCS file:
/home/cvs/ws-axis/c/tests/auto_build/testcases/client/cpp/FaultMappingDocClient.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FaultMappingDocClient.cpp 31 Jan 2005 16:38:18 -0000 1.11
+++ FaultMappingDocClient.cpp 15 Feb 2005 10:54:55 -0000 1.12
@@ -52,26 +52,37 @@
iResult = ws.div(i1, i2);
cout << "Result is " << iResult << endl;
}
- catch(MathOpsService_AxisClientException &me)
+ catch(DivByZeroStruct& dbzs)
{
- cout << "MathOpsService_AxisClientException: ";
- ISoapFault *fault = (ISoapFault *)me.getFault();
- const char* pcCmplxFaultName =
fault->getCmplxFaultObjectName().c_str();
- if(0 == strcmp("DivByZeroStruct",
pcCmplxFaultName))
- {
- DivByZeroStruct* p = (DivByZeroStruct
*)fault->getCmplxFaultObject();
- cout << "DivByZeroStruct Fault: \"" <<
p->varString << "\", " << p->varInt << ", " << p->varFloat << endl;
- }
- else if(0 == strcmp("SpecialDetailStruct",
pcCmplxFaultName))
- {
- SpecialDetailStruct* p =
(SpecialDetailStruct *)fault->getCmplxFaultObject();
- cout << "SpecialDetailStruct Fault: \""
<< p->varString << "\"" << endl;
- }
- else if(0 == strcmp("OutOfBoundStruct",
pcCmplxFaultName))
- {
- OutOfBoundStruct* p = (OutOfBoundStruct
*)fault->getCmplxFaultObject();
- cout << "OutOfBoundStruct Fault: \"" <<
p->varString << "\", " << p->varInt << ", \"" << p->specialDetail->varString <<
"\"" << endl;
- }
+ cout << "DivByZeroStruct Fault: \""
+ << dbzs.varString
+ << "\", "
+ << dbzs.varInt
+ << ", "
+ << dbzs.varFloat
+ << endl;
+ }
+ catch(SpecialDetailStruct& sds)
+ {
+ cout << "SpecialDetailStruct Fault: \""
+ << sds.varString
+ << "\""
+ << endl;
+ }
+ catch(OutOfBoundStruct& oobs)
+ {
+ cout << "OutOfBoundStruct Fault: \""
+ << oobs.varString
+ << "\", "
+ << oobs.varInt
+ << ", \""
+ << oobs.specialDetail->varString
+ << "\""
+ << endl;
+ }
+ catch(SoapFaultException& sfe)
+ {
+ cout << "SoapFaultException: " << sfe.what() <<
endl;
}
catch(AxisException& e)
{
1.4 +3 -3
ws-axis/c/tests/auto_build/testcases/output/FaultMappingDoc.cpp.out
Index: FaultMappingDoc.cpp.out
===================================================================
RCS file:
/home/cvs/ws-axis/c/tests/auto_build/testcases/output/FaultMappingDoc.cpp.out,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FaultMappingDoc.cpp.out 31 Jan 2005 16:38:18 -0000 1.3
+++ FaultMappingDoc.cpp.out 15 Feb 2005 10:54:56 -0000 1.4
@@ -3,11 +3,11 @@
Result is 2
1
Trying to div 10 by 0
-MathOpsService_AxisClientException: DivByZeroStruct Fault: "Division by zero
exception", 1, 10.52
+DivByZeroStruct Fault: "Division by zero exception", 1, 10.52
2
Trying to div 1000 by 5
-MathOpsService_AxisClientException: SpecialDetailStruct Fault: "You have
entered 1000 for the first parameter. 1000 is reserved. Please do not use it"
+SpecialDetailStruct Fault: "You have entered 1000 for the first parameter.
1000 is reserved. Please do not use it"
3
Trying to div 10 by -5
-MathOpsService_AxisClientException: OutOfBoundStruct Fault: "Out of bounds
exception", 2, "This bounds exception is a forced exception"
+OutOfBoundStruct Fault: "Out of bounds exception", 2, "This bounds exception
is a forced exception"
---------------------- TEST COMPLETE -----------------------------
\ No newline at end of file
1.1 ws-axis/c/include/axis/SoapFaultException.hpp
Index: SoapFaultException.hpp
===================================================================
/*
* 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.
*/
#ifndef __SOAPFAULTEXCEPTION_H_OF_AXIS_INCLUDED_
#define __SOAPFAULTEXCEPTION_H_OF_AXIS_INCLUDED_
#include <axis/GDefine.hpp>
#include <axis/AxisException.hpp>
AXIS_CPP_NAMESPACE_START
/**
* @class SoapFaultException
* @brief Superclass of all user-defined soap faults defined in the WSDL
*
* SoapFaultException is the superclass of all user faults that are defined
* in the WSDL. This enables a client application to catch all soap faults
* in a single catch block. To catch a specific soap fault, a client
* application should catch the class that represents the fault's complex
* type. SoapFaultException is a simple class that encapsulates the fault
* information and does not reference the SoapFault itself. This means it
* can clean it's own storage in its destructor so the client application
* doesn't have to.
*
* @author Mark Whitlock
*/
class STORAGE_CLASS_INFO SoapFaultException :public AxisException
{
public:
SoapFaultException();
SoapFaultException(AxisChar *code, AxisChar *string, AxisChar *actor,
int exceptionCode);
SoapFaultException(AxisException& ae);
virtual ~SoapFaultException();
virtual const AxisChar *getFaultCode() const;
virtual const AxisChar *getFaultString() const;
virtual const AxisChar *getFaultActor() const;
virtual void setFaultCode(const AxisChar *code);
virtual void setFaultString(const AxisChar *string);
virtual void setFaultActor(const AxisChar *actor);
virtual void setExceptionCode(int code);
/** @returns the fault string */
virtual const char* what() throw();
virtual const int getExceptionCode();
private:
AxisChar *m_code;
AxisChar *m_string;
AxisChar *m_actor;
int m_exceptionCode;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/SoapFaultException.cpp
Index: SoapFaultException.cpp
===================================================================
/*
* 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.
*/
#include <axis/SoapFaultException.hpp>
AXIS_CPP_NAMESPACE_START
/*
* All the methods in this class do a deep copy of the data so that the fault
can be
* processed whatever state the engine is in. Doing a deep copy means this
class owns
* the storage and can delete it in its destructor making client programming
simpler.
*/
#define STRINGCOPY(tgt,src) \
{
\
if (NULL != src && 0 != strlen(src)) \
{
\
tgt = new AxisChar[strlen(src)+1]; \
strcpy(tgt, src); \
} else tgt = NULL; \
}
SoapFaultException::SoapFaultException()
{
m_code = NULL;
m_string = NULL;
m_actor = NULL;
m_exceptionCode = 0;
}
SoapFaultException::SoapFaultException(
AxisChar *code, AxisChar *string, AxisChar *actor, int exceptionCode)
{
STRINGCOPY(m_code,code);
STRINGCOPY(m_string,string);
STRINGCOPY(m_actor,actor);
m_exceptionCode = exceptionCode;
}
SoapFaultException::SoapFaultException(AxisException& ae)
{
STRINGCOPY(m_string,ae.what());
m_exceptionCode = ae.getExceptionCode();
m_code = NULL;
m_actor = NULL;
}
SoapFaultException::~SoapFaultException()
{
if (NULL != m_code) delete [] m_code;
if (NULL != m_string) delete [] m_string;
if (NULL != m_actor) delete [] m_actor;
m_code = NULL;
m_string = NULL;
m_actor = NULL;
m_exceptionCode = 0;
}
const AxisChar *SoapFaultException::getFaultCode() const
{
return m_code;
}
const AxisChar *SoapFaultException::getFaultString() const
{
return m_string;
}
const AxisChar *SoapFaultException::getFaultActor() const
{
return m_actor;
}
void SoapFaultException::setFaultCode(const AxisChar *code)
{
STRINGCOPY(m_code,code);
}
void SoapFaultException::setFaultString(const AxisChar *string)
{
STRINGCOPY(m_string,string);
}
void SoapFaultException::setFaultActor(const AxisChar *actor)
{
STRINGCOPY(m_actor,actor);
}
void SoapFaultException::setExceptionCode(int code)
{
m_exceptionCode = code;
}
const char* SoapFaultException::what() throw()
{
return m_string;
}
const int SoapFaultException::getExceptionCode()
{
return m_exceptionCode;
}
AXIS_CPP_NAMESPACE_END