[prev in list] [next in list] [prev in thread] [next in thread] 

List:       axis-user
Subject:    Re: AxisFault, CustomException and code first approach
From:       "Martin Gainty" <mgainty () hotmail ! com>
Date:       2000-11-30 15:30:03
Message-ID: BAY108-DAV10257163015865BB30A6F3AE710 () phx ! gbl
[Download RAW message or body]

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! 


[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE>.hmmessage P {
	PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; \
PADDING-TOP: 0px }
BODY.hmmessage {
	FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>

<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY class=hmmessage bgColor=#ffffff>
<DIV><FONT face=Arial>Hello Par</FONT></DIV>
<DIV><FONT face=Arial><BR>I would first&nbsp;try to&nbsp;attenuate the axis2.xml 
parameter&nbsp; StackTrace&nbsp;e.g.</FONT></DIV>
<DIV><FONT face=Arial>&nbsp;&nbsp;&nbsp; &lt;parameter 
name="sendStacktraceDetailsWithFaults"&gt;false&lt;/parameter&gt;<BR><BR>Martin--</FONT></DIV>
 <BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 \
2px solid; MARGIN-RIGHT: 0px">  <DIV style="FONT: 10pt arial">----- Original Message \
----- </DIV>  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=par_malmqvist@hotmail.com href="mailto:par_malmqvist@hotmail.com">Pär 
  Malmqvist</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=axis-user@ws.apache.org 
  href="mailto:axis-user@ws.apache.org">axis-user@ws.apache.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, November 30, 2007 9:49 
  AM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> AxisFault, CustomException and 
  code first approach</DIV>
  <DIV><BR></DIV>Hi!<BR>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)<BR>The custom exception appears on the client 
  side in the AxisFault details field within &lt;exception&gt;&lt;exception&gt; 
  -tags together with a&nbsp;HUGE stack trace.<BR>&nbsp;<BR>I have checked the 
  source code for RPCMesssageReceiver and specially the section that handles the 
  AxisFault:<BR>} catch (InvocationTargetException e) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String 
  msg = 
  null;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  Throwable cause = 
  e.getCause();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  if (cause != null) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  msg = 
  cause.getMessage();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
  (msg == null) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  msg = "Exception occurred while trying to invoke service method " 
  +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  method.getName();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
  (cause instanceof AxisFault) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  log.debug(msg, 
  cause);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  throw 
  (AxisFault)cause;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  log.error(msg, 
  e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  throw new AxisFault(msg, e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } 
  catch(RuntimeException e) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw 
  AxisFault.makeFault(e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch 
  (Exception e) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String 
  msg = "Exception occurred while trying to invoke service method " 
  +<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  method.getName();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
  log.error(msg, 
  e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  throw AxisFault.makeFault(e);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  }<BR>}<BR>Could it be possible to change this code a little bit to throw an 
  AxisFault with a CustomException only in the details field? <BR>Like: The 
  AxisFault.getDetails() returns something 
  like&nbsp;&lt;CustomException&gt;custom message... 
  &lt;/CustomException&gt;<BR>It would be much easier to handle the exception on 
  the client side!<BR>What do you gurus 
  think?<BR>&nbsp;<BR>/Pär<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR><BR>&nbsp;<BR><BR>
  <HR>
  Invite your mail contacts to join your friends list with Windows Live Spaces. 
  It's easy! <A 
  href="http://spaces.live.com/spacesapi.aspx?wx_action=create&amp;wx_url=/friends.aspx&amp;mkt=en-us" \
  target=_new>Try it!</A> </BLOCKQUOTE></BODY></HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic