6 Replies Latest reply on Apr 27, 2010 2:53 PM by dkruitbosch

    cxf-osgi to cxf-nmr

    tcarr@clickfox.com

      I am new to this stuff, but I have been reading and trying things. I think I want something very simple, but am having trouble making it work.

       

      Basically, I want to accept a request from a webpage(wsdl), look at the contents and if the contents meet some criteria, send to (forward) some other service.

       

      Using the example, cxf-osgi, I can produce a service with wsdl to allow submitting a message. I would like to look at the message,(name), and if the name equals 'foo', I want to send the message to example cxf-nmr or nmr.

       

      I am truly using the examples as is for this experiment. I think the problem is I have over thought and or over read about this stuff, and the simple answer is eluding me.  Also, any thoughts as to if this is a bad practice to do routing like this or not would be helpful.

       

      Thanks.

        • 1. Re: cxf-osgi to cxf-nmr
          ffang

          Hi,

          cxf-osgi demonstrate cxf endpoint hosted in OSGi container using osgi http service as transport.

          If you want to route some message to cxf nmr endpoint, I think you'd better use camel with nmr component as router.

          You may need take a look at cxf-camel-nmr example shipped with kit, I believe it's very similar with your scenario.

           

          Freeman

          • 2. Re: cxf-osgi to cxf-nmr
            tcarr@clickfox.com

            Yes, the cxf-camle-nmr example is closer to what I want. The only problem I have is how do I create a http consumer like the cxf-osgi example to put in place of the timer endpoint of the cxf-camel-nmr example. I admit to be a little lazt and I like using the cxf-osgi example to create the wsdl and expose the service to the user. I would like to do the same and replace the timer event in the cxf-camel-example.

             

            I hope my scenario is pretty simple, I think others would want to do the same. For example: Have a webpage that users enter login information (cxf-osgi ex), then have this service or someother, do maybe a database dip to validate. If valid, route request to nmr service, if invalid, no route, return error message.

             

            Ultimately I would like to do some xpath routing with camel and start doing some of the really neat stuff. But I am kinda stuck with getting a wsdl in front of the router to the nmr services.

             

            I apologize again as I know I am asking simple questions, that I know are covered in documentations. I think I have just exceeded my saturation point and am now kinda spun out.

            • 3. Re: cxf-osgi to cxf-nmr
              ffang

              Hi,

              You can use servicemix-cxf-bc consumer  endpoint to expose webservice.

              The servicemix-cxf-bc consumer target a nmr endpoint in camel router,

              the camel router looks like

                        

                         

               

              Here the "from" part  uri "nmr:service:serviceNamespace[sep]serviceName" shuold be the target of servicemix-cxf-bc consumer, you can get more details about how the nmr URI looks like from

               

              the  "to" part is same as it in cxf-camel-nmr example, between the from and to, you can put any camel component to do anything you want.

              So you use servicemix-cxf-bc consumer instead of timer which can receive external message and send message to camel router, in this case, timer event isn't necessary at all.

              Hope this helps.

               

              Freeman

               

              http://camel.apache.org/nmr.html

              • 4. Re: cxf-osgi to cxf-nmr
                fsalceda

                I'm have the same problem with that. I have a cxf-consumer -> camel-router -> cxf-provider where:

                 

                {{{

                      

                }}}

                 

                When I display the nmr endpoints with "nmr:list"  I can only find:

                 

                {{{

                {http://piel.andago.com}andagoToPlusService:andagoToPlusEndpoint

                AndagoToPlus:AndagoToPlusHttpEndpoint

                }}}

                 

                And when I try to test the service, what I get is:

                 

                {{{

                11:48:02,726 | WARN  | 902@qtp-321796-0 | CxfBcComponent                   | ommon.endpoints.ConsumerEndpoint  184 | Target service ({http://fuse.piel.andago.com}AndagoToPlusIn) and endpoint (AndagoToPlusEndpointIn) specified, but no matching endpoint found.  Only the service will be used for routing.

                11:48:02,729 | WARN  | 902@qtp-321796-0 | NMR                              | .servicemix.nmr.core.ChannelImpl  293 | Error processing exchange [

                  id:        cc767bd8-c593-40d2-90b7-b011d8ebcbc7

                  mep:       InOut

                  status:    Active

                  role:      Consumer

                  target:    PropertyMatchingReference[{SERVICE_NAME={http://fuse.piel.andago.com}AndagoToPlusIn}]

                  operation: toPlus

                  properties: [

                      javax.jbi.messaging.MessageExchange = org.apache.servicemix.jbi.runtime.impl.InOutImpl@4a240d

                      javax.jbi.messaging.sendSync = true

                      javax.jbi.ServiceName = AndagoToPlusIn

                      org.apache.servicemix.correlationId = cc767bd8-c593-40d2-90b7-b011d8ebcbc7

                      javax.jbi.transaction.jta =

                      org.apache.servicemix.senderEndpoint = andagoToPlusService:andagoToPlusEndpoint

                  ]

                  In: [

                    content: <?xml version="1.0" encoding="UTF-8"?><piel:toPlus xmlns:piel="http://piel.andago.com">

                         <!Optional:>

                         <piel:a>2</piel:a>

                         <!Optional:>

                         <piel:b>3</piel:b>

                      </piel:toPlus>

                    properties: [

                      javax.jbi.messaging.protocol.headers = {}

                    ]

                  ]

                ]

                 

                org.apache.servicemix.nmr.api.ServiceMixException: Could not dispatch exchange. No matching endpoints.

                     at org.apache.servicemix.nmr.core.FlowRegistryImpl.dispatch(FlowRegistryImpl.java:110)

                     at org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:286)

                     at org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)

                     at org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:196)

                     at org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:101)

                     at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiInvokerInterceptor.handleMessage(CxfBcConsumer.java:773)

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

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

                     at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiChainInitiationObserver.onMessage(CxfBcConsumer.java:675)

                     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.HandlerList.handle(HandlerList.java:49)

                     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)

                11:48:02,731 | WARN  | 902@qtp-321796-0 | PhaseInterceptorChain            | ache.cxf.common.logging.LogUtils  361 | Interceptor for andagoToPlusService#toPlus has thrown exception, unwinding now

                org.apache.cxf.interceptor.Fault: Could not dispatch exchange. No matching endpoints.

                     at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiInvokerInterceptor.handleMessage(CxfBcConsumer.java:803)

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

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

                     at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiChainInitiationObserver.onMessage(CxfBcConsumer.java:675)

                     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.HandlerList.handle(HandlerList.java:49)

                     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)

                Caused by: org.apache.servicemix.nmr.api.ServiceMixException: Could not dispatch exchange. No matching endpoints.

                     at org.apache.servicemix.nmr.core.FlowRegistryImpl.dispatch(FlowRegistryImpl.java:110)

                     at org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:286)

                     at org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)

                     at org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:196)

                     at org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:101)

                     at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiInvokerInterceptor.handleMessage(CxfBcConsumer.java:773)

                     ... 18 more

                }}}

                • 5. Re: cxf-osgi to cxf-nmr
                  fsalceda

                  If I use the "jbi" endpoint :

                   

                  {{{

                     

                  }}}

                   

                  Now when I execute "nmr:list" I also get another endpoint:

                   

                  {{{

                  {http://piel.andago.com}andagoToPlusService:andagoToPlusEndpoint

                  AndagoToPlus:AndagoToPlusHttpEndpoint

                  AndagoToPlusIn:AndagoToPlusEndpointIn

                  }}}

                   

                  But It doesn't work getting another exception:

                   

                  {{{

                  12:05:36,296 | INFO  | x-camel-thread-3 | ManagementEndpointRegistry       | ement.ManagementEndpointRegistry   56 | Registering endpoint: org.apache.servicemix.nmr.core.InternalEndpointWrapper@621c1fd0 with properties {objectClass=[Ljava.lang.String;@1d0898, jbi.external=true, javax.jbi.servicedesc.ServiceEndpoint=org.apache.servicemix.common.ExternalEndpoint@1f72d0, service.id=308, SERVICE_NAME={http://camel.apache.org/schema/jbi}provider, NAME=provider:ID:127.0.1.1-12839337a83-4:0, UNTARGETABLE=true, ENDPOINT_NAME=ID:127.0.1.1-12839337a83-4:0}

                  12:05:36,305 | ERROR | -cxf-bc-thread-5 | CxfBcComponent                   | icemix.common.AsyncBaseLifeCycle  480 | Error processing exchange org.apache.servicemix.jbi.runtime.impl.InOutImpl@12504b

                  java.lang.NullPointerException

                       at org.apache.servicemix.cxfbc.CxfBcProvider.process(CxfBcProvider.java:206)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)

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

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

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

                  12:05:36,307 | ERROR | x-camel-thread-3 | DefaultErrorHandler              | rg.apache.camel.processor.Logger  248 | Failed delivery for exchangeId: 37128cfe-3d1a-424f-af84-26063be22129. Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException

                  java.lang.NullPointerException

                       at org.apache.servicemix.cxfbc.CxfBcProvider.process(CxfBcProvider.java:206)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)

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

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

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

                  12:05:36,307 | WARN  | x-camel-thread-3 | SimpleEndpoint                   | .common.endpoints.SimpleEndpoint   90 | SimpleEndpoint.fail called:

                  12:05:36,308 | WARN  | 902@qtp-321796-0 | PhaseInterceptorChain            | ache.cxf.common.logging.LogUtils  361 | Interceptor for andagoToPlusService#toPlus has thrown exception, unwinding now

                  org.apache.cxf.interceptor.Fault

                       at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiPostInvokerInterceptor.handleMessage(CxfBcConsumer.java:821)

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

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

                       at org.apache.servicemix.cxfbc.CxfBcConsumer$JbiChainInitiationObserver.onMessage(CxfBcConsumer.java:675)

                       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.HandlerList.handle(HandlerList.java:49)

                       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)

                  Caused by: java.lang.NullPointerException

                       at org.apache.servicemix.cxfbc.CxfBcProvider.process(CxfBcProvider.java:206)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)

                       at org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)

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

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

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

                  }}}

                   

                  I dont know what I doing wrong. I would appreciate some help.

                   

                  THX.

                  • 6. Re: cxf-osgi to cxf-nmr
                    dkruitbosch

                    Hi,

                     

                    In your camel config, the "from" becomes the exposed jbi endpoint that's available in the nmr for your camel router. So you should point your cxf-consumer-bc to that endpoint as the target service. And you should point your camel router to the jbi endpoint of your cxf service.

                    This was recently discussed in the following thread: http://fusesource.com/forums/thread.jspa?threadID=1735&tstart=15

                     

                    Also keep in mind that the soap envelope gets stripped from your input message when you set useSOAPEnvelope to false. Only the soap body will be send to your camel router and this should be a well formed xml document. I usually find it easier to leave the soap envelope untouched if routing between web services.

                     

                    Regards,

                     

                    Danny