6 Replies Latest reply on Apr 10, 2013 2:03 PM by wl880504

    How to create and deploy a Restful service to Fuse ESB

    wl880504

      I just need to create a restful service with Maven and deploy this service to FUSE ESB karaf container. I have been struggling for couple of days. I have searched a lot and tried many tutorials. But still can not get it work.

       

      Can someone provide me with a complete, clear and easy to follow tutorial?

        • 1. Re: How to create and deploy a Restful service to Fuse ESB
          ffang

          Hi,

           

          If you're using FUSE ESB 4.4.x, there is a cxf-jaxrs example shipped with kit.

          If you're using FUSE ESB 7.x, there is a rest example shipped with kit.

           

          I believe that's exactly what you're looking for.

           

          Freeman

          • 2. Re: How to create and deploy a Restful service to Fuse ESB
            wl880504

            Hi Freeman,

             

            I have figured it out but I got another question. First, here is my solution for basic OSGi restful service:

             

            Add cxf dependency:

             

             

             

            Then package it as bundle and deploy it to karaf. Now I can access the service by type:

            "http://localhost:8181/cxf/example/ping" in the web browser. It works good.

             

            Now my question is that this is a basic restful service which you can consume it through network by typing "http://localhost:8181/cxf/example/ping" in the web browser.

             

            I believe this restful service is deployed in embedded jetty container. Please correct me if I am wrong.

             

            What I really need is that creating a restful service which can be consumed through FUSE bus not network. How can I do this?

            • 3. Re: How to create and deploy a Restful service to Fuse ESB
              ffang

              Hi,

               

              I assume the FUSE BUS you mentioned here is NMR, right?

               

              You can publish your jaxrs service as NMR endpoint, which will use NMR transport, so that it can talk with other NMR endpoint, or other camel endpoint through camel-nmr.

               

              Just change the address to something like

              address="nmr:endpointName"

               

              Freeman

              • 4. Re: How to create and deploy a Restful service to Fuse ESB
                wl880504

                Hi Freeman,

                 

                I want to try the cxf-camel-nmr example to get a better understanding of nmr. But I am using FUSE ESB Enterprise 7.1. When I download cxf-camel-nmr-4.0.0.jar and deploy it to karaf container. I got:

                 

                missing package: META-INF.cxf.transport.nmr

                 

                How can I fix it? I think I need to install some features right?

                • 5. Re: How to create and deploy a Restful service to Fuse ESB
                  ffang

                  Yeah, install cxf-nmr feature.

                   

                  Freeman

                  • 6. Re: How to create and deploy a Restful service to Fuse ESB
                    wl880504

                    features install cxf-nmr fixes the problem. I have successfully tried out an example cxf-nmr at Link:[http://svn.apache.org/repos/asf/servicemix/smx4/features/trunk/examples/nmr/cxf-nmr/]

                     

                    This is about publishing a web service to nmr endpoint. Then I did the same thing to publish to restful service to nmr endpoint.

                     

                    Here is the spring beans.xml :

                     

                     

                         

                    <jaxrs:server id="exampleService" address="nmr:/mongo">

                          

                     

                    Here is the pom :

                     

                    (ServerImpl.java:72)

                         at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:151)

                         ... 21 more

                     

                    I got this error only when I add nmr to address in

                    <jaxrs:server id="exampleService" address="nmr:/mongo">

                    If I remove nmr from address, it works good but just a regular restful service.

                     

                    Do you know where is the problem? BTW, is there any example about publishing restful service to nmr endpoint? I searched a lot and end up with only web service & nmr.