2 Replies Latest reply on Nov 30, 2009 10:41 AM by Lars Rödiger

    Best Practices: JAX-WS Web-Services, Camel, Spring and OSGi ?

    Lars Rödiger Newbie

      Hallo,

       

      I've read plenty of tutorials by now, none facing a problem of a real comlex scenario with Web-Services and Routing. What I have in mind is the following.

      Each message send to http://localhost:8181/cxf/WebService is be directed to the Java-Class (see attachment "EndpointImpl.java") implementing this service. Afterwards the message body (which is supposed to be in XML format) is send to an NMR-Endpoint (nmr:endpoint:Router), the message is routed to another NMR-Endpoint in regard to the content (the query is expressed in XPath). At the end the message is send to an external Web-Service.

           I want the functionality implemented in different OSGi-Bundles. So I've started to create a first Bundle which uses the cxf-codegen-plugin/wsdl2java to generate a Java-Skeleton from the specified WSDL. The Spring-XML-Configuration I created therefore is in the attachment "beans.xml". So far calling the Web-Service, e.g. from SOAP-UI works. The problem is that I can't reference a jax-ws:endpoint in Camel, with cxf:cxfEndpoint it does work. My first question is what is the main difference between jax-ws:endpoint and jax-ws:endpoint, can both use WS-Addressing and further WS-extensions? Refering to the bean "ProxyEndpoint" results in polling the bean, this isn't my intention. So, I also considered to call the NMR-Endpoint from within "EndpointImpl.java". The Camel-Context is injected but I get always a NullpointerException from org.apache.servicemix.camel.ServiceMixProducer.process (line 48, 

      ...

      47: NMR nmr = getEndpoint().getComponent().getNmr();

      48: Channel client = nmr.createChannel();

      ...).

      Does anyone have a solution for this problem or may a suggestion how to implement this scenario? When I've finished this scenario I will create a blog with a step-by-step tutorial. But first, I need you help.

       

      Thanks.

       

      Lars Rödiger

        • 1. Re: Best Practices: JAX-WS Web-Services, Camel, Spring and OSGi ?
          Dave Stanley Novice

          Hi Lars,

           

          So jaxws:endpoint is a standard cxf endpoint, cxf:cxfEndpoint is a camel enabled cxf endpoint. It implements camels DefaultEndpoint so it can fully participate in camel routes.

           

           

          can both use WS-Addressing and further WS-extensions? ..

           

           

          I think it should be possible with cxf:cxfEndpoint. I haven't tried it but I think something like this should work:

           

           <cxf:cxfEndpoint id="serviceEndpoint" address="http://localhost:9000/SoapContext/SoapPort"
                        wsdlURL="testutils/hello_world.wsdl"
                        serviceClass="org.apache.hello_world_soap_http.Greeter"
                        endpointName="s:SoapPort"
                        serviceName="s:SOAPService"
                   xmlns:s="http://apache.org/hello_world_soap_http">
                 <cxf:features>
                      <wsa:addressing></wsa:addressing>
                 </cxf:features>
             </cxf:cxfEndpoint>
          

           

          In terms of the best approach, its probably easiest to do the whole thing in a camel route .. assuming the wsa stuff above works.

           

          Hope this helps,

          /Dave

           

          Edited by: dstanley on Nov 30, 2009 3:36 PM

          • 2. Re: Best Practices: JAX-WS Web-Services, Camel, Spring and OSGi ?
            Lars Rödiger Newbie

            Thank you Dave. I will give it a try.