You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2012/01/04 16:25:45 UTC

Re: setting custom fault code on exceptions

On Thursday, December 29, 2011 3:29:29 PM Guy Pardon wrote:
> Hi,
> 
> What is the easiest way to set the "Code" element of an exception thrown by
> my @WebMethod?

I THINK if the "cause" of an exception that is thrown is a SOAPFaultException, 
the information from that SOAPFault is used to populate the returned fault.  
Thus, you can set the code there.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: About interceptor chain in the security fault case

Posted by Daniel Kulp <dk...@apache.org>.
On Friday, January 06, 2012 8:16:49 AM XiLai Dai wrote:
> Hello,
> 
> We have a interceptor which is used to get operation name and something
> else. It works for most of use cases but not works with the security fault
> case. After some debugging, the order of the interceptors like this:
> 
> org.apache.cxf.ws.policy.PolicyInInterceptor@4db9dc 
> (message.getExchange().getBindingOperationInfo() = null)
> ourInterceptor@1d00259  (message.getExchange().getBindingOperationInfo() =
> null) ............
> org.apache.cxf.ws.security.wss4j.UsernameTokenInterceptor@1b8935b
> (message.getExchange().getBindingOperationInfo() = null)   //Exception if
> password is wrong and stop iterate over interceptor chain. ............
> org.apache.cxf.interceptor.URIMappingInterceptor@14d583a
> (message.getExchange().getBindingOperationInfo() ok)
> 
> who can give some proposal on how to get the operation name in the security
> fault case? Thanks!

In general, you cannot.    If you have unique SOAP Actions for the operations, 
the SOAPActionInInterceptor may have found one for you, but without that, you 
won't be able to get the operation at this point in the processing.

The basic reason is that the soap body may be encrypted.   Or maybe a JAX-WS 
handler needs to manipulate it.   Of an interceptor may want to transform it 
for backwords compatibility.   Or it may not even be XML (maybe fastinfoset or 
json or something).      Basically, until the chain proceeds into the various 
DatabindingInInterceptor's where it will then look at the elements in the body 
and find the operation, it's likely not going to have the operation name.



-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

About interceptor chain in the security fault case

Posted by XiLai Dai <xl...@talend.com>.
Hello,

We have a interceptor which is used to get operation name and something else. It works for most of use cases but not works with the security fault case.
After some debugging, the order of the interceptors like this: 

org.apache.cxf.ws.policy.PolicyInInterceptor@4db9dc  (message.getExchange().getBindingOperationInfo() = null)
ourInterceptor@1d00259  (message.getExchange().getBindingOperationInfo() = null)
............
org.apache.cxf.ws.security.wss4j.UsernameTokenInterceptor@1b8935b (message.getExchange().getBindingOperationInfo() = null)   //Exception if password is wrong and stop iterate over interceptor chain.
............
org.apache.cxf.interceptor.URIMappingInterceptor@14d583a (message.getExchange().getBindingOperationInfo() ok)

who can give some proposal on how to get the operation name in the security fault case? Thanks!

Regards.
Xilai

Re: setting custom fault code on exceptions

Posted by Stas Ostapenko <st...@gmail.com>.
Hi Guy.

Take a look at this link
http://willemjiang.blogspot.com/2011/01/how-to-map-soap-fault-message-with.html
Maybe it can help a little.

BR,
Stas

On Thu, Jan 5, 2012 at 11:12 AM, Guy Pardon <gu...@atomikos.com> wrote:
> Indeed, it works. Cool!
>
> Guy
>
> On 4-jan-2012, at 16:25, Daniel Kulp wrote:
>
> On Thursday, December 29, 2011 3:29:29 PM Guy Pardon wrote:
>> Hi,
>>
>> What is the easiest way to set the "Code" element of an exception thrown by
>> my @WebMethod?
>
> I THINK if the "cause" of an exception that is thrown is a SOAPFaultException,
> the information from that SOAPFault is used to populate the returned fault.
> Thus, you can set the code there.
>
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>
> Dr. Guy Pardon | Atomikos BVBA | a 'Cool Vendor' by Gartner in 2011
>
> CTO
> Phone: +32 15 61 30 55 | Email: guy@atomikos.com | Twitter: http://twitter.com/guypardon | Skype: guypardon | YahooIM: guypardon
>
> Europe: CET (local time: http://www.timeanddate.com/worldclock/city.html?n=48)
>
> Visit us at http://www.atomikos.com/
>
> Visit our blog at http://blog.atomikos.com/
>
> Visit the Atomikos TransactionsEssentials Community at http://fogbugz.atomikos.com/default.asp?community
>
> Visit the Atomikos Training site at http://www.atomikos.com/Main/AtomikosTraining
>
> The information in this email is confidential and only meant for the addressee(s). The content of this email is informal and will not be legally binding for Atomikos.
>

Re: setting custom fault code on exceptions

Posted by Guy Pardon <gu...@atomikos.com>.
Indeed, it works. Cool!

Guy

On 4-jan-2012, at 16:25, Daniel Kulp wrote:

On Thursday, December 29, 2011 3:29:29 PM Guy Pardon wrote:
> Hi,
> 
> What is the easiest way to set the "Code" element of an exception thrown by
> my @WebMethod?

I THINK if the "cause" of an exception that is thrown is a SOAPFaultException, 
the information from that SOAPFault is used to populate the returned fault.  
Thus, you can set the code there.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Dr. Guy Pardon | Atomikos BVBA | a 'Cool Vendor' by Gartner in 2011

CTO
Phone: +32 15 61 30 55 | Email: guy@atomikos.com | Twitter: http://twitter.com/guypardon | Skype: guypardon | YahooIM: guypardon

Europe: CET (local time: http://www.timeanddate.com/worldclock/city.html?n=48)

Visit us at http://www.atomikos.com/

Visit our blog at http://blog.atomikos.com/

Visit the Atomikos TransactionsEssentials Community at http://fogbugz.atomikos.com/default.asp?community

Visit the Atomikos Training site at http://www.atomikos.com/Main/AtomikosTraining

The information in this email is confidential and only meant for the addressee(s). The content of this email is informal and will not be legally binding for Atomikos. 


Re: setting custom fault code on exceptions

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, January 04, 2012 6:03:16 PM Guy Pardon wrote:
> Yes, however with the SOAPFaultException you move away from the fault
> messages defined in the WSDL (since you can't set the Detail easily).

I think with CXF you can do both.  If you throw your "MyCustomException" class 
defined in the WSDL, but set the cause of the exception to be a 
SOAPFaultException that fills in the message and faultcode and such, but NOT 
the details, then CXF will use the original exception for the details part.   

Dan



> So for now I prefer to stay with the generated code of "Server" as per jaxws
> mappings of my exceptions and stick with WSDL compliance. I guess it is a
> known 'issue' in the spec?
> 
> Thanks anyway,
> And: happy 2012!
> 
> Guy
> 
> On 4-jan-2012, at 16:25, Daniel Kulp wrote:
> 
> On Thursday, December 29, 2011 3:29:29 PM Guy Pardon wrote:
> > Hi,
> > 
> > What is the easiest way to set the "Code" element of an exception thrown
> > by my @WebMethod?
> 
> I THINK if the "cause" of an exception that is thrown is a
> SOAPFaultException, the information from that SOAPFault is used to populate
> the returned fault. Thus, you can set the code there.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: setting custom fault code on exceptions

Posted by Guy Pardon <gu...@atomikos.com>.
Yes, however with the SOAPFaultException you move away from the fault messages defined in the WSDL (since you can't set the Detail easily). 

So for now I prefer to stay with the generated code of "Server" as per jaxws mappings of my exceptions and stick with WSDL compliance. I guess it is a known 'issue' in the spec? 

Thanks anyway, 
And: happy 2012!

Guy

On 4-jan-2012, at 16:25, Daniel Kulp wrote:

On Thursday, December 29, 2011 3:29:29 PM Guy Pardon wrote:
> Hi,
> 
> What is the easiest way to set the "Code" element of an exception thrown by
> my @WebMethod?

I THINK if the "cause" of an exception that is thrown is a SOAPFaultException, 
the information from that SOAPFault is used to populate the returned fault.  
Thus, you can set the code there.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Dr. Guy Pardon | Atomikos BVBA | a 'Cool Vendor' by Gartner in 2011

CTO
Phone: +32 15 61 30 55 | Email: guy@atomikos.com | Twitter: http://twitter.com/guypardon | Skype: guypardon | YahooIM: guypardon

Europe: CET (local time: http://www.timeanddate.com/worldclock/city.html?n=48)

Visit us at http://www.atomikos.com/

Visit our blog at http://blog.atomikos.com/

Visit the Atomikos TransactionsEssentials Community at http://fogbugz.atomikos.com/default.asp?community

Visit the Atomikos Training site at http://www.atomikos.com/Main/AtomikosTraining

The information in this email is confidential and only meant for the addressee(s). The content of this email is informal and will not be legally binding for Atomikos.