You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Pär Malmqvist <pa...@hotmail.com> on 2007/11/30 15:49:16 UTC
AxisFault, CustomException and code first approach
Hi!
When creating a web service using existing business logic with "code first" approach I dont think custom exceptions are handled the way it should. (Axis2 1.3)The custom exception appears on the client side in the AxisFault details field within <exception><exception> -tags together with a HUGE stack trace.
I have checked the source code for RPCMesssageReceiver and specially the section that handles the AxisFault:
} catch (InvocationTargetException e) { String msg = null; Throwable cause = e.getCause(); if (cause != null) { msg = cause.getMessage(); } if (msg == null) { msg = "Exception occurred while trying to invoke service method " + method.getName(); } if (cause instanceof AxisFault) { log.debug(msg, cause); throw (AxisFault)cause; } log.error(msg, e); throw new AxisFault(msg, e); } catch(RuntimeException e) { throw AxisFault.makeFault(e); } catch (Exception e) { String msg = "Exception occurred while trying to invoke service method " + method.getName(); log.error(msg, e); throw AxisFault.makeFault(e); }}
Could it be possible to change this code a little bit to throw an AxisFault with a CustomException only in the details field?
Like: The AxisFault.getDetails() returns something like <CustomException>custom message... </CustomException>
It would be much easier to handle the exception on the client side!
What do you gurus think?
/Pär
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
RE: AxisFault, CustomException and code first approach
Posted by Pär Malmqvist <pa...@hotmail.com>.
Hello!
Thanks Martin, I tried a couple of configs, but unfortunately it doesn't seem to work.
<parameter name="sendStacktraceDetailsWithFaults">true</parameter> --> getDetail() returns huge stacktrace
<parameter name="sendStacktraceDetailsWithFaults">false</parameter> --> getDetail() returns null
I have also tried:
<parameter name="DrillDownToRootCauseForFaultReason">false</parameter> and
<parameter name="DrillDownToRootCauseForFaultReason">true</parameter> but it has no effect in this case.
So the question is still:
Could it be possible to change the fault handling code a little bit to throw an AxisFault with a CustomException only in the details field? Like: The AxisFault.getDetails() returns something like <CustomException>custom message... </CustomException>
/Pär
From: mgainty@hotmail.comTo: axis-user@ws.apache.orgSubject: Re: AxisFault, CustomException and code first approachDate: Thu, 30 Nov 2000 10:30:03 -0500
Hello Par
I would first try to attenuate the axis2.xml parameter StackTrace e.g.
<parameter name="sendStacktraceDetailsWithFaults">false</parameter>Martin--
----- Original Message -----
From: Pär Malmqvist
To: axis-user@ws.apache.org
Sent: Friday, November 30, 2007 9:49 AM
Subject: AxisFault, CustomException and code first approach
Hi!When creating a web service using existing business logic with "code first" approach I dont think custom exceptions are handled the way it should. (Axis2 1.3)The custom exception appears on the client side in the AxisFault details field within <exception><exception> -tags together with a HUGE stack trace. I have checked the source code for RPCMesssageReceiver and specially the section that handles the AxisFault:} catch (InvocationTargetException e) { String msg = null; Throwable cause = e.getCause(); if (cause != null) { msg = cause.getMessage(); } if (msg == null) { msg = "Exception occurred while trying to invoke service method " + method.getName(); } if (cause instanceof AxisFault) { log.debug(msg, cause); throw (AxisFault)cause; } log.error(msg, e); throw new AxisFault(msg, e); } catch(RuntimeException e) { throw AxisFault.makeFault(e); } catch (Exception e) { String msg = "Exception occurred while trying to invoke service method " + method.getName(); log.error(msg, e); throw AxisFault.makeFault(e); }}Could it be possible to change this code a little bit to throw an AxisFault with a CustomException only in the details field? Like: The AxisFault.getDetails() returns something like <CustomException>custom message... </CustomException>It would be much easier to handle the exception on the client side!What do you gurus think? /Pär
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline