cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Vest Hansen" <karmazi...@gmail.com>
Subject Re: Throwing faults from within an Interceptor
Date Mon, 26 Nov 2007 10:36:13 GMT
Hello Jervis.

> Make sure the exception thrown from your interceptor is declared as an exception on the
operation being invoked

It is. It is declared to be thrown in the WSDL and on my implementation methods.

> was the MyFault class generated by wsdltojava? does it have the WebFault annotation?

Yes and yes.

> Take a look into WebFaultOutInterceptor. handleMessage(), the code might tell you why
WebFaultOutInterceptor did not recognize your exception as a checked exception.

Looks like it should work, but I can't help thinking that it might be
because my interceptor runs PRE_PROTOCOL. Are we certain that faults
always go through this WebFaultOutInterceptor?


2007/11/26, Liu, Jervis <jliu@iona.com>:
> Hi, it is possible to throw a checked Exception from CXF interceptors. Make sure the
exception thrown from your interceptor is declared as an exception on the operation being
invoked, otherwise this exception will not be recognized as a checked Exception. Also was
the MyFault class generated by wsdltojava? does it have the WebFault annotation? The checked
exception is unmarshalled by WebFaultOutInterceptor and its super class FaultOutInterceptor.
If the exception is not recognized as checked exception by WebFaultOutInterceptor, the exception
will be handled by the default protocol binding fault interceptors such as Soap11FaultOutInterceptor
and Soap12FaultOutInterceptor. Take a look into WebFaultOutInterceptor. handleMessage(), the
code might tell you why WebFaultOutInterceptor did not recognize your exception as a checked
exception.
>
> Let me know if you have any further questions,
>
> Jervis
>
> > -----Original Message-----
> > From: Christian Vest Hansen [mailto:karmazilla@gmail.com]
> > Sent: 2007年11月23日 17:56
> > To: cxf-user@incubator.apache.org
> > Subject: Throwing faults from within an Interceptor
> >
> > I have a WSDL that defines MyFault and all of my operations can
> > potentially throw this fault. This fault has some custom elements and
> > stuff, so it is not an ordinary SoapFault, and it got its own
> > Exception class when I generated my Java code.
> >
> > When I throw this fault from within an operation in my WebServiceImpl
> > class, all of the custom cruft I put in this fault gets marshalled
> > correctly.
> >
> > However, I also have an Interceptor (that operates in the
> > Phase.PRE_PROTOCOL phase) that want to throw faults as well, and
> > preferably faults defined in my WSDL. So in the Interceptors
> > handleMessage() I do something like this:
> >
> > throw new Fault(new MyFault("Bad stuff"));
> >
> > When I do this, I only get an ordinary soap fault with a "Bad stuff"
> > fault string, but all of the things that are custom to the MyFault
> > dosn't get marshalled properly.
> >
> > So, is there any way that I can remedy this? Can I make an interceptor
> > throw a properly marshalled custom soap fault?
> >
> > CXF version 2.0.3.
> >
> > --
> > Venlig hilsen / Kind regards,
> > Christian Vest Hansen.
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>


-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.
Mime
View raw message