2 Replies Latest reply on Nov 8, 2008 2:40 PM by anielson

    REST HTTP Request and Camel

    anielson

      I need an example on how to receive an HTTP request (POST method with Plain Old XML body) and process the received message using Camel. For instance, receive XML data using HTTP and writing the filtered file in the filesystem. Can anyone helpon this?

        • 1. Re: REST HTTP Request and Camel
          edelln

          Hi,

           

          You will need to build your SU and then put these into one SA (Servicemix Assembly). You can use the Servicemix archetypes to get you started see - http://servicemix.apache.org/maven-archetypes.html

           

          To receive XML data using HTTP - you can try using smx-http soap-consumer

           

          eg.

           

          
          
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns:http="http://servicemix.apache.org/http/1.0"  xmlns:xxx="http://example.org/test">
                  <classpath>
                          <location>.</location>
                  </classpath>
            <http:soap-consumer service="xxx:ConsumerService"
                           interfaceName="xxx:ConsumerInterface"
                           endpoint="ConsumerServiceEndpoint"
                           targetService="xxx:camelService"
                           locationURI="http://10.254.251.226:8194/test4/"
                           defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
                           wsdl="classpath:consumerService.wsdl"
                           useJBIWrapper="true"></http:soap-consumer>
                           
          </beans> 
          

           

           

          This SU will use the servicemix-http component

           

          And then setup another SU that uses servicemix-camel component

           

          In your camel-context file you could have something like

           

          
          <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
                        xmlns:xxx="http://example.org/test">
                
              <route>
                <from uri="jbi:endpoint:http://example.org/test/CamelService"></from>
                <to   uri="file:target/reports/report.txt"></to>
              </route>
          </camelContext>
          

           

           

          RouteBuilder.java

           

          public class CamleFileExampleBuilder extends RouteBuilder {
              public void configure() throws Exception {
              }
          }
          

           

           

          for more information on the camel file see

          http://activemq.apache.org/camel/file.html

           

          hope this helps, Edell.

          • 2. Re: REST HTTP Request and Camel
            anielson

            And what about using camel jetty component? Did someone try this?