You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hyjshanghai <hy...@gmail.com> on 2011/03/14 10:54:05 UTC

How to Register a "Default Soap Fault Handler" in Camel?

Just like handling exception by the "onException" DSL in Camel, I want to
handle any soap fault message returned by cxf endpoints in a single handler.
How can I realize it in Camel? Is there anything like "onSoapFault"?

--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p3556065.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by Willem Jiang <wi...@gmail.com>.
Hi Claus,

Actually, Current camel-cxf consumer calls the doneUoW, but it is called before sending the message back to the client. I will check if we can do some thing by applying a customer interceptor in CXF side to rethrow the exception out.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On May 16, 2014 at 10:44:20 PM, Claus Ibsen (claus.ibsen@gmail.com) wrote:
> Hi
>  
> Willem if you are listening. Sounds like CXF consumer need to do like
> http consumer does in CamelServlet, where the consumer creates the UoW
> and do the doneUoW after the response has been written by CXF.
>  
> Then if CXF fails, then we could detect this and have the UoW fail in Camel.
>  
> But that requires CXF can report the failure to Camel somehow.
>  
>  
>  
> On Fri, May 9, 2014 at 12:33 PM, ponderMuse wrote:
> > I am now able to handle some SoapFaults via the onException() method, but not
> > necessarily all of them. I am interested in handling a SoapFault which takes
> > place during the service's response write process.
> >
> > The scenario I am testing is where the web service tries to write the
> > response back to the client but the client is no longer there (i.e.
> > client-server connection lost). In this case, cxf logs a stacktrace of type
> > org.apache.cxf.interceptor.Fault: Could not send Message, and I can see in
> > the stacktrace that it is intercepted by: MessageSenderInterceptor. But my
> > route's onException() method is never called. I have tried onException() for
> > the following Exception classes: java.lang.Exception.class,
> > java.net.SocketException.class and javax.xml.stream.XMLStreamException.class  
> > (all the ones that are shown in the cxf stacktrace) but yet my onException()
> > method is never called.
> >
> > Does the onException() code need to be placed in a specific section of my
> > service's route in this case? At the moment I've placed it just after
> > from(uri) and after my final to(ExchangePattern.InOut, mqUri) where mqUri
> > has the following form:
> > "wmq:REQUEST_Q?replyTo=RESPONSE_Q&replyToType=Exclusive&requestTimeout=45000".  
> >
> > Cheers,
> > PM.
> >
> >
> >
> > --
> > View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p5750961.html  
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>  
>  
>  
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>  


Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Willem if you are listening. Sounds like CXF consumer need to do like
http consumer does in CamelServlet, where the consumer creates the UoW
and do the doneUoW after the response has been written by CXF.

Then if CXF fails, then we could detect this and have the UoW fail in Camel.

But that requires CXF can report the failure to Camel somehow.



On Fri, May 9, 2014 at 12:33 PM, ponderMuse <po...@googlemail.com> wrote:
> I am now able to handle some SoapFaults via the onException() method, but not
> necessarily all of them. I am interested in handling a SoapFault which takes
> place during the service's response write process.
>
> The scenario I am testing is where the web service tries to write the
> response back to the client but the client is no longer there (i.e.
> client-server connection lost). In this case, cxf logs a stacktrace of type
> org.apache.cxf.interceptor.Fault: Could not send Message, and I can see in
> the stacktrace that it is intercepted by: MessageSenderInterceptor. But my
> route's onException() method is never called. I have tried onException() for
> the following Exception classes: java.lang.Exception.class,
> java.net.SocketException.class and javax.xml.stream.XMLStreamException.class
> (all the ones that are shown in the cxf stacktrace) but yet my onException()
> method is never called.
>
> Does the onException() code need to be placed in a specific section of my
> service's route in this case? At the moment I've placed it just after
> from(uri) and after my final to(ExchangePattern.InOut, mqUri) where mqUri
> has the following form:
> "wmq:REQUEST_Q?replyTo=RESPONSE_Q&replyToType=Exclusive&requestTimeout=45000".
>
> Cheers,
> PM.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p5750961.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by ponderMuse <po...@googlemail.com>.
I am now able to handle some SoapFaults via the onException() method, but not
necessarily all of them. I am interested in handling a SoapFault which takes
place during the service's response write process.

The scenario I am testing is where the web service tries to write the
response back to the client but the client is no longer there (i.e.
client-server connection lost). In this case, cxf logs a stacktrace of type
org.apache.cxf.interceptor.Fault: Could not send Message, and I can see in
the stacktrace that it is intercepted by: MessageSenderInterceptor. But my
route's onException() method is never called. I have tried onException() for
the following Exception classes: java.lang.Exception.class,
java.net.SocketException.class and javax.xml.stream.XMLStreamException.class
(all the ones that are shown in the cxf stacktrace) but yet my onException()
method is never called.

Does the onException() code need to be placed in a specific section of my
service's route in this case? At the moment I've placed it just after
from(uri) and after my final to(ExchangePattern.InOut, mqUri) where mqUri
has the following form:
"wmq:REQUEST_Q?replyTo=RESPONSE_Q&replyToType=Exclusive&requestTimeout=45000".

Cheers,
PM.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p5750961.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by ponderMuse <po...@googlemail.com>.
Hi, I am having a lot of trouble configuring my Camel CXF route to handle
SOAPFaults itself instead of letting CXF handle them. In order to achieve
this, I have read various online documentation and posts but I have yet to
be able to handle these faults/exceptions in my code.

For my service:
- I have set <camelContext handleFault="true" />.
- I have specified an onException(Exception.class)... in my service's route
configure() method.
- I have set the entry point into the service's route as:
from("cxf:/AService?dataFormat=PAYLOAD").

Yet, every time I run a test to purposely force a SoapFault through, it only
ever gets handled in the CXF PhaseInterceptorChain and not passed through to
my own fault handling code.

Can anybody give me some guidance on what I am missing, or point me to a
running example project which does exactly this so I can compare configs
against mine?

My service is using camel-cxf-2.12.2 APIs and cxf-api-2.7.11 APIs.

Thanks in advance for any help on this, PM.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p5750958.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 15, 2011 at 3:19 AM, hyjshanghai <hy...@gmail.com> wrote:
> Thanks.
>
> I have set handleFault to "true" on my camel context. But the processor
> configured in onException(java.lang.Exception) still fails to execute if the
> cxf endpoint returns soap fault message.
>
> The cxf endpoint that returns soap fault message uses MESSAGE as the data
> format.
>
> A post  http://www.mail-archive.com/users@camel.apache.org/msg06709.html
> here  suggests that PAYLOAD should be used as the data format in order to
> make handleFault effective.
> Is this true? I don't understand why from that post.
>

Yeah my understanding of MESSAGE is that its a "raw" mode, where you
gotta do all the parsing and processing of the SOAP message yourself.



> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p3645623.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by hyjshanghai <hy...@gmail.com>.
Thanks.

I have set handleFault to "true" on my camel context. But the processor
configured in onException(java.lang.Exception) still fails to execute if the
cxf endpoint returns soap fault message.

The cxf endpoint that returns soap fault message uses MESSAGE as the data
format.

A post  http://www.mail-archive.com/users@camel.apache.org/msg06709.html
here  suggests that PAYLOAD should be used as the data format in order to
make handleFault effective.
Is this true? I don't understand why from that post. 

--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p3645623.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Register a "Default Soap Fault Handler" in Camel?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 14, 2011 at 10:54 AM, hyjshanghai <hy...@gmail.com> wrote:
> Just like handling exception by the "onException" DSL in Camel, I want to
> handle any soap fault message returned by cxf endpoints in a single handler.
> How can I realize it in Camel? Is there anything like "onSoapFault"?
>

There is a handleFault you can set on the camel context or per route
that turns SOAP faults into exceptions, which mean the Camel
onException etc. can catch the exception and handle those.



> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-Register-a-Default-Soap-Fault-Handler-in-Camel-tp3556065p3556065.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/