cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu, Jervis" <j...@iona.com>
Subject RE: Throwing faults from within an Interceptor
Date Tue, 27 Nov 2007 02:30:55 GMT


> -----Original Message-----
> From: Christian Vest Hansen [mailto:karmazilla@gmail.com]
> Sent: 2007年11月26日 18:36
> To: cxf-user@incubator.apache.org
> Subject: Re: Throwing faults from within an Interceptor
> 
> 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?
> 

It should, if you are using JAX-WS frontend. Where your interceptor sits does not really matter,
as when the exception is thrown from the outbound interceptor chain, CXF will start a new
interceptor chain to deal with exceptions (fault out interceptor chain). Can you set your
log level to FINE to see what interceptors you have in your fault out chain. 

Thanks,
Jervis

> 
> 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.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Mime
View raw message