5 Replies Latest reply on Nov 26, 2014 3:29 PM by AYMAN a

    Propagate SoapFault with simple Camel proxy

    Miguel Fernández Martínez Newbie

      I'm trying to create a simple WS proxy using Switchyard 1.1 with Camel:

      --> PromotedService --> Camel --> ProxifiedService

      With the current configuration I'm able to send and recieve messages without any problem. However, when the ProxifiedService throws a SoapFault it is not propagated to the caller of the PromotedService.

      What can I do to ensure the the PromotedServiceCaller receives the SOAPFault as reponse?

      This is what I have tried so far:

      onException(SoapFault.class)   
                         .process(  
                            new Processor() {  
                               public void process(Exchange exchange) throws Exception {  
      //This method is never called.....
                                                      SoapFault fault = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
                                                                      SoapFault.class);
                                                      exchange.getOut().setFault(true);
                                                      exchange.getOut().setBody(fault);
                                              exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, false);
                                  exchange.removeProperty("CamelExceptionCaught");  
                               }  
                            })  
                         .handled(true)  
                         .end();
                     
              from("switchyard://PromotedService")
                  .process(myProc) // --> I just add some headers here to the original request.
                  .handleFault()  
                  .to("switchyard://ProxifiedService").handleFault().end();


      This is the SOAPFault generated by the ProxifiedService:

       

      <soapenv:Envelope xmlns:ser="http://service.admin.ws.my.company/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

      <soapenv:Header>

      </soapenv:Header>

      <soapenv:Body>

         <soapenv:Fault>

            <faultcode>soapenv:Server</faultcode>

            <faultstring>Missing valid token.</faultstring>

         </soapenv:Fault>

      </soapenv:Body>

       

      And this is the stacktrace I see in the log:

       

      14:45:40,324 ERROR [org.apache.camel.processor.DefaultErrorHandler] (http-/127.0.0.1:8080-1) Failed delivery for (MessageId: ID-ESVT-63783-1410266534060-5-8 on ExchangeId: ID-ESVT-63783-1410266534060-5-4). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelException: javax.xml.transform.dom.DOMSource@2b1b287b: org.apache.camel.CamelException: javax.xml.transform.dom.DOMSource@2b1b287b

          at org.apache.camel.processor.interceptor.HandleFaultInterceptor.handleFault(HandleFaultInterceptor.java:68) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.HandleFaultInterceptor$1.done(HandleFaultInterceptor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:82) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache$1.done(ProducerCache.java:315) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.SendProcessor$2$1.done(SendProcessor.java:125) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:67) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:115) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.HandleFaultInterceptor.process(HandleFaultInterceptor.java:41) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) [camel-core-2.10.0.jar:2.10.0]

          at org.switchyard.component.camel.SwitchYardConsumer.invokeCamelProcessor(SwitchYardConsumer.java:187) [switchyard-component-camel-switchyard-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.component.camel.SwitchYardConsumer.handleMessage(SwitchYardConsumer.java:95) [switchyard-component-camel-switchyard-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:29) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:46) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.Pipeline.process(Pipeline.java:117) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:104) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.TryProcessor.process(TryProcessor.java:78) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:46) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:360) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:331) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:227) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:331) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:153) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:106) [camel-core-2.10.0.jar:2.10.0]

          at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:92) [camel-core-2.10.0.jar:2.10.0]

          at org.switchyard.bus.camel.ExchangeDispatcher.dispatch(ExchangeDispatcher.java:87) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.bus.camel.CamelExchange.sendInternal(CamelExchange.java:234) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.bus.camel.CamelExchange.send(CamelExchange.java:171) [switchyard-bus-camel-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.component.soap.InboundHandler.invoke(InboundHandler.java:317) [switchyard-component-soap-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:112) [switchyard-component-soap-1.1.0.Final.jar:1.1.0.Final]

          at org.switchyard.component.soap.endpoint.BaseWebService.invoke(BaseWebService.java:41) [switchyard-component-soap-1.1.0.Final.jar:1.1.0.Final]

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45]

          at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]

          at org.jboss.ws.common.invocation.AbstractInvocationHandlerJSE.invoke(AbstractInvocationHandlerJSE.java:108)

          at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:149) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178) [cxf-rt-frontend-jaxws-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:66) [cxf-rt-frontend-jaxws-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:129) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_45]

          at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_45]

          at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) [cxf-api-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:237) [cxf-rt-transports-http-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:95) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:156) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:225) [cxf-rt-transports-http-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:145) [cxf-rt-transports-http-2.6.6-redhat-3.jar:2.6.6-redhat-3]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

          at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135) [jbossws-cxf-server-4.1.3.Final-redhat-3.jar:4.1.3.Final-redhat-3]

          at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140) [jbossws-spi-2.1.2.Final-redhat-1.jar:2.1.2.Final-redhat-1]

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

          at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45]

       

      Thank you!

       

      Message was edited by: Miguel Fernández Martínez I added some extra information about the SOAPFault message and the stacktrace.

        • 1. Re: Propagate SoapFault with simple Camel proxy
          Miguel Fernández Martínez Newbie

          After following this link https://camel.apache.org/cxf.html#CXF-HowtothrowaSOAPFaultfromCamel

          now I'm able to create a custom Fault, but I'm not able to obtain the original fault message "Missing valid token" from the proxified service.

          Instead of that I got a strange message: "javax.xml.transform.dom.DOMSource@136bd". How can I obtain the original fault message in order to simulate a transparent propagation of the soapfault?

           

          This is the code I have now:

           

          onException(Exception.class)  

                             .process(  

                                new Processor() {  

                                   public void process(Exchange exchange) throws Exception {          

                                  SoapFault fault = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, SoapFault.class);

                                  System.out.println("Fault: " +  fault); // --> This returns NULL

           

                                  Exception excep = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

                                  System.out.println("excep: " +  excep);

                                  System.out.println("excep message: " + excep.getMessage());

                                  System.out.println("excep cause: " +  excep.getCause());

                                                         

                                                  SoapFault SOAP_FAULT = new SoapFault(excep.getMessage(), SoapFault.FAULT_CODE_CLIENT);

                                                  Element detail = SOAP_FAULT.getOrCreateDetail();

                                                  Document doc = detail.getOwnerDocument();

                                                  Text tn = doc.createTextNode("this is a test");

                                                  detail.appendChild(tn);

                                                 

                                                  exchange.getOut().setFault(true);

                                                  exchange.getOut().setBody(SOAP_FAULT);

                                                         

                                                  exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, false);

                                      exchange.removeProperty("CamelExceptionCaught");  

                                   }  

                                })  

                             .handled(true)  

                             .end();

                         

                  from("switchyard://ProxyService")

                      .process(myProc) // -->just some logging and addition of headers

                      .handleFault()  

                      .to("switchyard://ProxifiedService").end();

          • 2. Re: Propagate SoapFault with simple Camel proxy
            Jorge Morales Master

            Hi,

            Can I ask what do you do in the camel route?

            If you attach the composite.xml at least the relevant bits it might be easier to help.

            • 3. Re: Propagate SoapFault with simple Camel proxy
              Miguel Fernández Martínez Newbie

              I don't have a composite.xml, only a switchyard.xml. The Camel route is defined by Java.

              This is the part of the Switchyard config file related to Camel:

               

              <sca:component name="ProxyService">

                    <camel:implementation.camel>

                      <camel:java class="com.company.my.RouterCamel"/>

                    </camel:implementation.camel>

                    <sca:service name="PromotedService">

                      <sca:interface.wsdl interface="META-INF/AuthWS.wsdl#wsdl.porttype(AuthWS)"/>

                    </sca:service>

                    <sca:reference name="ProxifiedService" >

                      <sca:interface.wsdl interface="META-INF/AuthWS.wsdl#wsdl.porttype(AuthWS)"/>

                    </sca:reference>

                  </sca:component>

              • 4. Re: Propagate SoapFault with simple Camel proxy
                Jorge Morales Master

                Hi,

                Both of your component ends are wsdl defined, so in your camel route you are dealing with whatever xml type it uses, and it seems as you can not easily manipulate.

                You can implement an xsl transform to modify that doc, and maybe achieve what you want.

                It is a pity, but one of the simplest use cases, a proxy, in switchyard is getting very difficult for people to implement. Let's hope that next version adds more quickstarts around this topic, as well as ads some goodies to ease the scenario.

                • 5. Re: Propagate SoapFault with simple Camel proxy
                  AYMAN a Newbie

                  Miguel

                  You are getting "javax.xml.transform.dom.DOMSource@136bd" because when camel wraps the fault with an exception object it is executing the toString method on the DOMSource object (representing the fault).

                   

                  In my case , i wanted to see the fault message as a string object. I am assuming you can apply a transformer to your reference to convert the DOMSource to a String or other object, however instead i chose to override apache camel implementation of wrapping fault.



                  In my route


                  RouteDefinition definition = from("switchyard://AccountLookupApplicationService");

                          definition.addInterceptStrategy(new com.xxx.esb.switchyard.creditbrowser.td.creditappservice.HandleFault());

                   

                  Overriding HandleFault camel implementation

                  public final class HandleFault implements InterceptStrategy {

                   

                      public Processor wrapProcessorInInterceptors(CamelContext context,

                              ProcessorDefinition<?> definition, Processor target, Processor nextTarget) throws Exception {

                   

                          return new com.xxx.esb.switchyard.creditbrowser.td.creditappservice.HandleFaultInterceptor(target);

                      }

                   

                      /**

                       * A helper method to return the HandleFault instance

                       * for a given {@link org.apache.camel.CamelContext} if one is enabled

                       *

                       * @param context the camel context the handlefault intercept strategy is connected to

                       * @return the stream cache or null if none can be found

                       */

                      public static HandleFault getHandleFault(CamelContext context) {

                          List<InterceptStrategy> list = context.getInterceptStrategies();

                          for (InterceptStrategy interceptStrategy : list) {

                              if (interceptStrategy instanceof HandleFault) {

                                  return (HandleFault)interceptStrategy;

                              }

                          }

                          return null;

                      }

                   

                      @Override

                      public String toString() {

                          return "HandleFault";

                      }

                  }

                   

                   

                  public class HandleFaultInterceptor extends DelegateAsyncProcessor {

                   

                      public HandleFaultInterceptor() {

                      }

                   

                      public HandleFaultInterceptor(Processor processor) {

                          super(processor);

                      }

                   

                      @Override

                      public String toString() {

                          return "HandleFaultInterceptor[" + processor + "]";

                      }

                   

                      @Override

                      public boolean process(final Exchange exchange, final AsyncCallback callback) {

                          return getProcessor().process(exchange, new AsyncCallback() {

                              public void done(boolean doneSync) {

                                  try {

                                      // handle fault after we are done

                                      handleFault(exchange);

                                  } finally {

                                      // and let the original callback know we are done as well

                                      callback.done(doneSync);

                                  }

                              }

                          });

                      }

                   

                      /**

                       * Handles the fault message by converting it to an Exception

                       */

                      protected void handleFault(Exchange exchange) {

                          // Take the fault message out before we keep on going

                          if (exchange.hasOut() && exchange.getOut().isFault()) {

                              final Object faultBody = exchange.getOut().getBody();

                              if (faultBody != null && exchange.getException() == null) {

                                  // remove fault as we are converting it to an exception

                                  exchange.setOut(null);

                                  if (faultBody instanceof Throwable) {

                                      exchange.setException((Throwable) faultBody);

                                  } else {

                                      if(faultBody instanceof DOMSource) {

                                          try {

                                          Transformer serializer = SAXTransformerFactory.newInstance()

                                                  .newTransformer();

                                          serializer.setOutputProperty(OutputKeys.INDENT, "yes");

                                          // serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,

                                          // "yes");

                                          serializer.setOutputProperty(

                                                  "{http://xml.apache.org/xslt}indent-amount", "2");

                                          // serializer.setOutputProperty("{http://xml.customer.org/xslt}indent-amount",

                                          // "2");

                                          StreamResult res = new StreamResult(new ByteArrayOutputStream());

                                          serializer.transform((DOMSource) faultBody, res);

                                          String output = new String(

                                                  ((ByteArrayOutputStream) res.getOutputStream())

                                                          .toByteArray());

                                          exchange.setException(new CamelException(output));

                                          } catch(Exception ex) {

                                              exchange.setException(new CamelException(faultBody.toString()));

                                          }

                                      } else {

                                          exchange.setException(new CamelException(faultBody.toString()));

                                      }

                                  }

                              }

                          }

                      }

                   

                  }