7 Replies Latest reply on Apr 29, 2011 9:02 AM by kaczan

    Process after cxf enpoint

    kaczan

      Hi, I'm new in Fuse and i cannot handle with 2 things.

       

      The problem is:

      I've got two bundles. First called channel that expose web service. Configuration looks like:

       

       

      I need to use two diffrent namespaces in both wsdl. But ofcourse I must change namespaces in requests and enpoints. I wrote interceptor that change request. But i can't change response. I want ask do you know better solution to change this namespaces between invoke cxf enpoints?

      Or if i need to use interceptor or processor how to change output message, becouse the problem is that in response message content I've got some bushes in the text and automagiclly it is change only at the end (in soupui where I test this).

      Can you help?

       

      Edited by: kaczan on Apr 28, 2011 6:43 PM

       

      Edited by: kaczan on Apr 28, 2011 6:51 PM

        • 1. Re: Process after cxf enpoint
          njiang

          Hi,

          As you are using the Message dataformat, you don't need to add a CXF interceptor to change the namespace. You can use the transform to do this kind of job easily.

             <route>
                <from uri="cxf:bean:serviceEnpoint"></from>
                <to uri="xslt:org/apache/camel/spring/processor/request.xsl"></to>
                <to uri="cxf:bean:targetEnpoint"></to>
                <to uri="xslt:org/apache/camel/spring/processor/response.xsl"></to>
             </route>
          

           

          Willem

          • 2. Re: Process after cxf enpoint
            kaczan

            I tried, and i have still same problem with web service output.

             

            It's my logs:

             

            12:02:37,787 | INFO  | Request-thread-1 | beforeRequest                    | rg.apache.camel.processor.Logger   88 | Exchange[BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sap="http://location.com/channel/sap">

               <soapenv:Header>

                  <sap:requestHeader>

                     <sap:requestDate>?</sap:requestDate>

                     <sap:user>?</sap:user>

                  </sap:requestHeader>

               </soapenv:Header>

               <soapenv:Body>

                  <sap:getTeamSchedule>

                     <sap:user>?</sap:user>

                     <sap:district>?</sap:district>

                     <sap:plannersGroup>?</sap:plannersGroup>

                     <sap:dateFrom>?</sap:dateFrom>

                     <sap:dateTo>?</sap:dateTo>

                  </sap:getTeamSchedule>

               </soapenv:Body>

            </soapenv:Envelope>]

            12:02:37,881 | INFO  | Request-thread-1 | getTeamScheduleRequest           | rg.apache.camel.processor.Logger   88 | Exchange[BodyType:String, Body:<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ah:requestHeader xmlns:ah="http://location.com/service/ah"><ah:requestDate>?</ah:requestDate><ah:user>?</ah:user></ah:requestHeader></soapenv:Header><soapenv:Body><ah:getTeamSchedule xmlns:ah="http://location.com/service/ah"><ah:user>?</ah:user><ah:district>?</ah:district><ah:plannersGroup>?</ah:plannersGroup><ah:dateFrom>?</ah:dateFrom><ah:dateTo>?</ah:dateTo></ah:getTeamSchedule></soapenv:Body></soapenv:Envelope>]

            12:02:37,897 | INFO  | Request-thread-1 | ReflectionServiceFactoryBean     | ory.ReflectionServiceFactoryBean  400 | Creating Service TeamScheduleService from WSDL: http://localhost:8088/teamScheduleAS?wsdl

            12:02:37,975 | INFO  | Request-thread-1 | fromResponse                     | rg.apache.camel.processor.Logger   88 | Exchange[BodyType:sun.net.www.protocol.http.HttpURLConnection.HttpInputStream, Body:[BUSHESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS&#322;&#261;&#261;&#347;&#261;&#347;ó&#261;&#347;&#322;&#347;&#261;ó]

            12:02:37,975 | ERROR | Request-thread-1 | DefaultErrorHandler              | rg.apache.camel.processor.Logger  248 | Failed delivery for exchangeId: 4819e701-c1f0-4cb0-8d90-1fa64102cdac. Exhausted after delivery attempt: 1 caught: org.apache.camel.ExpectedBodyTypeException: Could not extract IN message body as type: interface javax.xml.transform.Source body is: org.apache.camel.converter.stream.InputStreamCache@906eac

            org.apache.camel.ExpectedBodyTypeException: Could not extract IN message body as type: interface javax.xml.transform.Source body is: org.apache.camel.converter.stream.InputStreamCache@906eac

                 at org.apache.camel.builder.xml.XsltBuilder.getSource(XsltBuilder.java:256)

                 at org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:74)

                 at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:95)

                 at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:65)

                 at org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:97)

                 at org.apache.camel.processor.SendProcessor$1.doInProducer(SendProcessor.java:95)

                 at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:146)

                 at org.apache.camel.processor.SendProcessor.doProcess(SendProcessor.java:94)

                 at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:82)

                 at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)

                 at org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:53)

                 at org.apache.camel.processor.DelegateProcessor.proceed(DelegateProcessor.java:82)

                 at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:93)

                 at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)

                 at org.apache.camel.processor.RedeliveryErrorHandler.processExchange(RedeliveryErrorHandler.java:177)

                 at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:143)

                 at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:88)

                 at org.apache.camel.processor.DefaultErrorHandler.process(DefaultErrorHandler.java:49)

                 at org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:228)

                 at org.apache.camel.processor.Pipeline.process(Pipeline.java:74)

                 at org.apache.camel.processor.UnitOfWorkProcessor.processNext(UnitOfWorkProcessor.java:66)

                 at org.apache.camel.processor.DelegateProcessor.process(DelegateProcessor.java:48)

                 at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:67)

                 at org.apache.servicemix.camel.nmr.ServiceMixConsumer.process(ServiceMixConsumer.java:69)

                 at org.apache.servicemix.nmr.core.InternalEndpointWrapper.process(InternalEndpointWrapper.java:86)

                 at org.apache.servicemix.nmr.core.ChannelImpl.process(ChannelImpl.java:255)

                 at org.apache.servicemix.nmr.core.ChannelImpl$1.run(ChannelImpl.java:215)

                 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                 at java.lang.Thread.run(Thread.java:619)

            12:02:38,006 | INFO  | 6@qtp-12195796-0 | teamInfo                         | rg.apache.camel.processor.Logger   88 | Exchange[BodyType:null, Body:null]

            12:02:38,006 | WARN  | 6@qtp-12195796-0 | PhaseInterceptorChain            | ache.cxf.common.logging.LogUtils  361 | Interceptor for TeamScheduleService has thrown exception, unwinding now

            java.lang.NullPointerException

                 at org.apache.camel.component.cxf.interceptors.RawMessageContentRedirectInterceptor.handleMessage(RawMessageContentRedirectInterceptor.java:48)

                 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)

                 at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:76)

                 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)

                 at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)

                 at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:312)

                 at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:276)

                 at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)

                 at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)

                 at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)

                 at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

                 at org.mortbay.jetty.Server.handle(Server.java:326)

                 at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)

                 at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)

                 at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)

                 at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)

                 at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)

                 at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)

                 at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

             

             

            So as you can see the output message is stream and cannot by change into string. I tried change it by transform.. but UTF-8 enconding change nothing, maybe there are other encoding? Other format that text (but text/xml is show in header). Have you got any idea why it's happen?

             

            Edited by: kaczan on Apr 29, 2011 10:09 AM

            • 3. Re: Process after cxf enpoint
              davsclaus

              Add a  before the XSLT endpoints

              • 4. Re: Process after cxf enpoint
                davsclaus

                What version of Fuse are you using?

                • 5. Re: Process after cxf enpoint
                  kaczan

                  I'm use 4.2 version.

                  • 6. Re: Process after cxf enpoint
                    kaczan

                    I try convert body and I have still the same error but it's on converting point. The are also more bushes, becouse the top part of stack trace are "converted".

                    • 7. Re: Process after cxf enpoint
                      kaczan

                      I found solution. The respons was gzip data. When i make unmarshal it's start working ok.

                       

                       

                      So if somone want change something in web service respons he could expect gzip format in message.