Hi all. This is a great topic -- how to manage exceptions for services built on POJOs. If it is as easy as the link Anne Manes provided (http://wso2.org/library/171) then throwing exceptions might well be included in the main Axis2 docs at http://ws.apache.org/axis2/1_1_1/pojoguide.html).
But I just tried throwing an exception out of a POJO's method (the basis for a service as described here: http://ws.apache.org/axis2/1_1_1/pojoguide.html), and the exception doesn't seem to make it back to the client. Does the QName need to match one of the faults defined in the client stub? In any case, the code looks like this: public void test() throws AxisFault { throw new AxisFault(new QName("http://test.org", "FaultCode", "test"), "FaultReason", new Exception("This is a test Exception")); } On the server, the trace looks like this: FaultReason; nested exception is: java.lang.Exception: This is a test Exception java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) [much deleted] Caused by: org.apache.axis2.AxisFault: FaultReason; nested exception is: java.lang.Exception: This is a test Exception at com.myco.Service.test(Service.java:45) ... 48 more Caused by: java.lang.Exception: This is a test Exception ... 49 more DEBUG 16:24:37,843 org.apache.axis2.AxisFault: FaultReason; nested exception is: java.lang.Exception: This is a test Exception DEBUG 16:24:37,843 isReplyRedirected: FaultTo is null. Returning isReplyRedirected DEBUG 16:24:37,843 isReplyRedirected: ReplyTo is null. Returning false On 4/3/07, Anne Thomas Manes <[EMAIL PROTECTED]> wrote:
See http://wso2.org/library/171. On 4/3/07, Chan, Herman <[EMAIL PROTECTED]> wrote: > > > > > Hi all: > > > > I am relatively new to Axis 2 and web services in general, so please bear > with me if I ask any stupid questions. > > > > I am writing a very simple web service that would return a list of > directories on a server. However, if certain directories does not exists, > I'd like a throw an error back to the calling client. > > > > I am using the POJO approach to create web services using axis2, so is it > good enough for me to throw a plain Exception or do I have to do more? What > is the best practice in doing error handling in web services? > > > > Thanks in advance. > > > > Herman Chan > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
