You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vpd <vi...@yahoo.com> on 2012/11/06 14:09:46 UTC

CXF SOAP Fault handling

I am new to Camel and CXF. I am trying to post process the fault messages
that are thrown from my webservice. But CXF throws them as Fault exception
only and hence the camel routing is aborted and the error handler is
invoked.
How can I tweak Camel or CXF to get the fault message just as received by
the CXF itself>
Is there any configuration by which I can attain this? 
Or Do I need to provide an Interceptor to achieve this? 
Or Do I need to handle in Error handler? 

I searched and found, with interceptors I could update the message. But felt
there should be a simple way to go for it.

Please advice.




--
View this message in context: http://camel.465427.n5.nabble.com/CXF-SOAP-Fault-handling-tp5722219.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF SOAP Fault handling

Posted by Christian Müller <ch...@gmail.com>.
Will the "onException" definition work for you? There you can handle the
exception (e.g. execute an alternative route) and abord the routing or
continue the normal routing.

Sent from a mobile device
Am 06.11.2012 16:36 schrieb "vpd" <vi...@yahoo.com>:

> Thanks Willem for your quick response. We tried with no error handler but
> even then routing aborted once SOAP fault is thrown.
>
> I feel that I haven't provided the context clearly. Hence described below.
>
>         We have a web service, which can return proper business fault or
> can raise
> an exception as depicted in the below SOAP Responses. In CFX, is their way
> to differentiate the BUSINESS FAULT from an Exception?
> As I understood, CFX treats all SOAP Fault responses as Exceptions and
> aborts the chain.
>
> Response 1 : Business Fault
> <SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema "
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance ">
>    <SOAP-ENV:Body>
>       <SOAP-ENV:Fault>
>          <faultcode>SOAP-ENV:Server</faultcode>
>          <faultstring>BAD ALBUM</faultstring>
>          <detail>
>             <ns2:FMT2 xmlns:ns2="http://test ">
>                <standard/>
>             </ns2:FMT2>
>          </detail>
>       </SOAP-ENV:Fault>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> Response 2 : Exception
> <SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema "
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance ">
>    <SOAP-ENV:Body>
>       <SOAP-ENV:Fault>
>          <faultcode>SOAP-ENV:Server</faultcode>
>          <faultstring>javax.ejb.EJBException: ASJ.ejb.005044 (Failed in
> component: sap.com/Test2WSEAR) Exception raised from invocation of public
> test.OrderItunes
> test.ReceiveOrderTest2ImplBean.receiveOrderTest(test.OrderTest) throws
> test.FMT2_Exception,test.FMT1_Exception method on bean instance
> test.ReceiveOrderTest2ImplBean@7846c638  for bean
>
> sap.com/Test2WSEAR*annotation|Test2WS.jar*annotation|ReceiveOrderTest2ImplBean
> in application sap.com/Test2WSEAR.; nested exception is:
> java.lang.RuntimeException: REALLY BAD SINGER!!</faultstring>
>          <detail>
>
> <yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException
> xmlns:yq1="http://sap-j2ee-engine/client-runtime-error
> ">javax.ejb.EJBException:
>
> ….</yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException>
>          </detail>
>       </SOAP-ENV:Fault>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> If I have a route like this
>         <route id=””>
>                 <from uri=”…”>
>                 <to uri=”cfx:bean:beanName>
>                 <to uri=”component:other”>
>         </route>
>
> If the first cfx endpoint (cfx:bean:beanName) for invoking the web service,
> returns a business fault,  I want to extract structure under <detail> and
> pass it on the next processing(component:other).  How it can be achieved?
> Currently, when a SOAP FAULT, occurs, CXF sets an Exception to the Exchange
> and the camel pipeline will not move to the next processor.
> (Soap11InFaultInterceptor sets the exception to Exchange.)
>
> -- vpd.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/CXF-SOAP-Fault-handling-tp5722219p5722235.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: CXF SOAP Fault handling

Posted by vpd <vi...@yahoo.com>.
Thanks Willem for your quick response. We tried with no error handler but
even then routing aborted once SOAP fault is thrown.

I feel that I haven't provided the context clearly. Hence described below.

	We have a web service, which can return proper business fault or can raise
an exception as depicted in the below SOAP Responses. In CFX, is their way
to differentiate the BUSINESS FAULT from an Exception? 
As I understood, CFX treats all SOAP Fault responses as Exceptions and
aborts the chain.

Response 1 : Business Fault
<SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema "
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "> 
   <SOAP-ENV:Body> 
      <SOAP-ENV:Fault> 
         <faultcode>SOAP-ENV:Server</faultcode> 
         <faultstring>BAD ALBUM</faultstring> 
         <detail> 
            <ns2:FMT2 xmlns:ns2="http://test "> 
               <standard/> 
            </ns2:FMT2> 
         </detail> 
      </SOAP-ENV:Fault> 
   </SOAP-ENV:Body> 
</SOAP-ENV:Envelope>

Response 2 : Exception
<SOAP-ENV:Envelope xmlns:xs="http://www.w3.org/2001/XMLSchema "
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/ "
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "> 
   <SOAP-ENV:Body> 
      <SOAP-ENV:Fault> 
         <faultcode>SOAP-ENV:Server</faultcode> 
         <faultstring>javax.ejb.EJBException: ASJ.ejb.005044 (Failed in
component: sap.com/Test2WSEAR) Exception raised from invocation of public
test.OrderItunes
test.ReceiveOrderTest2ImplBean.receiveOrderTest(test.OrderTest) throws
test.FMT2_Exception,test.FMT1_Exception method on bean instance
test.ReceiveOrderTest2ImplBean@7846c638  for bean
sap.com/Test2WSEAR*annotation|Test2WS.jar*annotation|ReceiveOrderTest2ImplBean
in application sap.com/Test2WSEAR.; nested exception is:
java.lang.RuntimeException: REALLY BAD SINGER!!</faultstring> 
         <detail> 
           
<yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException
xmlns:yq1="http://sap-j2ee-engine/client-runtime-error
">javax.ejb.EJBException:
….</yq1:com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException> 
         </detail> 
      </SOAP-ENV:Fault> 
   </SOAP-ENV:Body> 
</SOAP-ENV:Envelope>

If I have a route like this 
	<route id=””>
		<from uri=”…”>
		<to uri=”cfx:bean:beanName>
		<to uri=”component:other”>
	</route>

If the first cfx endpoint (cfx:bean:beanName) for invoking the web service,
returns a business fault,  I want to extract structure under <detail> and
pass it on the next processing(component:other).  How it can be achieved?
Currently, when a SOAP FAULT, occurs, CXF sets an Exception to the Exchange
and the camel pipeline will not move to the next processor.
(Soap11InFaultInterceptor sets the exception to Exchange.) 

-- vpd.



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-SOAP-Fault-handling-tp5722219p5722235.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF SOAP Fault handling

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

You can disable the ErrorHandling like this, if you just proxy the service like below route.

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route errorHandlerRef="noErrorHandler">
<from uri="cxf:bean:routerEndpoint" />
<to uri="cxf:bean:serviceEndpoint" />
</route>
</camelContext>
<bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>



-- 
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Tuesday, November 6, 2012 at 9:09 PM, vpd wrote:

> I am new to Camel and CXF. I am trying to post process the fault messages
> that are thrown from my webservice. But CXF throws them as Fault exception
> only and hence the camel routing is aborted and the error handler is
> invoked.
> How can I tweak Camel or CXF to get the fault message just as received by
> the CXF itself>
> Is there any configuration by which I can attain this? 
> Or Do I need to provide an Interceptor to achieve this? 
> Or Do I need to handle in Error handler? 
> 
> I searched and found, with interceptors I could update the message. But felt
> there should be a simple way to go for it.
> 
> Please advice.
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-SOAP-Fault-handling-tp5722219.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).