Hi All,
Question : How do I do the exception handling in axis cpp client so that
correct relevant message is printed out ?
Detailed description below :
I am new to Web services. I have a requirement to write C++ client to call a
customer's web services. My client code has to run on many platforms : Win32,
AIX, Solaris, HP-Itanium, Linux. I am playing with both gSoap and Axis C++
client versions on Windows first.
I am using axis-c-1.6b-Win32-trace-bin binaries on Windows 2000 Advanced Server
(my laptop).
My customer's web service is written in Axis for Java.
First I tried simple examples, and they are working fine : Calculator, hello
world etc.
But when I try calling my customer's web service (real life) example with axis
client as well as with gSoap client, I am unable to get the actual exception
string.
Question : How do I do the correct exception handling so that correct relevant
message is printed out ?
Bacause I am sending invalid business data, I get HTTP 500. But as you can see
in the return HTTP message below, the business exception / fault string is
"TruckID EXAMPLE-5 cannot be found" but instead I get "Cannot deserialize" with
Axis and "HTTP 500 error" with gSOap.
This post is only regarding Axis, so I am not expecting any replies regarding
gSOap.
Below, I have used MacDonalds as an example. They are not my customer :)
Thanks a LOT in advance !!
Below is my client code : ------------------------------------
try
{
CustomerService service;
allocSvcObj.setUsername("username");
allocSvcObj.setPassword("password");
TruckObject * createdTruckId = service.callCustomerMethod(
"EXAMPLE-5","BBB" );
}
catch(AxisException& e)
{
printf("Exception : %s\n", e.what());
}
I also tried :
catch( SoapFaultException & e)
{
const char *excpCode = e.getFaultCode();
const char *excpMessage = e.getFaultString();
printf("Got Soap Fault : code : [%d], message : [%s]\n", excpCode,
excpMessage);
}
catch( AxisException& e)
{
int iExceptionCode = e.getExceptionCode();
const char *excpMessage = e.getMessage();
printf("Got axis exception : code : [%d], message : [%s]\n",
iExceptionCode, excpMessage);
}
Below is my client run result : ------------------------------------
Exception : Cannot deserialize the requested element
if I print e.exceptionCode(), I get 72.
Below is what the customer's http server returned :
------------------------------------
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=EE7CCB1E9C3F32E1E340387CEFB3C39C; Path=/dm
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Thu, 19 Feb 2009 14:35:29 GMT
Connection: close
291
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.generalException</faultcode><faultstring>E20010
TruckID EXAMPLE-5 cannot be found [R00007]; nested exception is:
com.MacDonalds.common.exceptions.RecordDeletedException: E20010 TruckID
EXAMPLE-5 cannot be found [R00007]</faultstring><detail><ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">mp-srv-lin02</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>