11 Replies Latest reply on Jan 12, 2011 11:32 PM by njiang

    REST services

    allanon76

      Hi all,

       

      what is the best way to expose an external REST based web service through the ESB?

       

      Thanks in advance for your attention.

       

      Best,

       

      Michele

        • 1. Re: REST services
          davsclaus

          Have you seen the developing REST guide

          http://fusesource.com/docs/esb/4.3/cxf_rest/index.html

          • 2. Re: REST services
            allanon76

            thank you for the response.

             

            But I don't need to implement from scratch a new REST service.

             

            I already have it exposed somewhere in the web and just want to expose it trough the the ESB....

            • 3. Re: REST services
              davsclaus

              You want to proxy it? Then you can use a generic http service to proxy it.

               

              With Camel you can do a simple route to proxy it:

              fron("jetty:0.0.0.0:9123/myapp/mypath?bridgeEndpoint=true&throwExcpetionOnFailure=false").to("http:url_of_real_service?bridgeEndpoint =true&throwExcpetionOnFailure=false");
              

               

              There is also a Camel CXF proxy example which may inspire you

              http://camel.apache.org/cxf-proxy-example.html

              • 4. Re: REST services
                allanon76

                Hi,

                thank you for your suggestion.

                I'm trying to do what you suggested but...

                 

                I'm using apache-servicemix-4.3.0-fuse-03-00

                 

                starting from camel-osgi-example from camel distribution I've configured the camelContext.xml as described at the end of this post. I added the dependency to camel-jetty 2.5.0 in the pom.xml. I built everything (mvn clean/compile/install)

                The osgi bundle is correctly installed (without error in the servicemix log ):

                 

                camel-example-osgi (2.4.0)

                 

                but when I start it I've this error

                 

                Error executing command: The bundle "org.apache.camel.camel-example-osgi_2.4.0 [

                395]" could not be resolved. Reason: Missing Constraint: Import-Package: org.apa

                che.camel.component.jetty; version="[2.4.0,2.5.0)"

                 

                Any suggestion?

                Is the camelContext below correct to proxy the http call?

                 

                Thanks in advance.

                 

                 

                • 5. Re: REST services
                  davsclaus

                  You need to use features to install those Camel components

                  http://fusesource.com/docs/esb/4.3/esb_deploy_osgi/DeployFeatures.html

                   

                  If you do a features:list you should see all the Camel components. Then install the camel-jetty feature

                   

                  features:install camel-jetty

                   

                  And also camel-cxf feature as well (if not already installed)

                  • 6. Re: REST services
                    allanon76

                    both cxf and jetty are already installed but with different version

                     

                    camel-jetty

                    camel-cxf

                     

                    so could be a version issue?

                    • 7. Re: REST services
                      ffang

                      Hi,

                       

                      Yeah, this is a version issue, as FUSE ESB 4.3.0-fuse-03-00 use camel 2.4.0-fuse-02-00,

                      so you just need specify camel version as 2.4.0-fuse-02-00 in your example pom.xml

                       

                      Freeman

                      • 8. Re: REST services
                        njiang

                        It could be better if you just have one version of camel-*. As there could have some difference between the camel-core 2.4.0-fuse-02-00 and camel-core 2.4.0-fuse-03-00.

                         

                        Willem

                        • 9. Re: REST services
                          allanon76

                          Thanks a lot to all,

                           

                          I tried in many ways to getting it to work.

                          But I'm unable to run it in fuse esb

                           

                          I tried to modify the version, but in this way I've compile error even if I've the package in my local mvn repository and this means I cannot produce the final jar to be deployed in the ESB.

                           

                          I'm a bit frustrated as this is just the start point of my project and I'm encountering lot of problem

                          • 10. Re: REST services
                            davsclaus

                            You should use the versions which is shipped with Fuse ESB as its been tested together to ensure they work together.

                            • 11. Re: REST services
                              allanon76

                              It works now.

                               

                               

                               

                              Thanks to all.