Search code examples
xmlhttpapache-camelapache-servicemix

Apache Camel - sending xml parameter to http endpoint doesnt work


Below is my route

    from("activemq:queue:request")
    .routeId("urlRoute")
    .setExchangePattern(ExchangePattern.InOut)
    .convertBodyTo(String.class)
    .to("http://mydomain:8080/my-bin/myProgram.pgm?xmlData=<head><user>username</user><pass>password</pass><data>Some data</data></head>")
    .process(new Processor() {
       public void process(Exchange e) throws Exception {
         log.info("Response : "+MessageHelper.extractBodyAsString(e.getIn()));
       }
     })
    .to("activemq:queue:response")

The above route works fine since the to endpoints is hardcoded with xml data in http endpoint.... If i replace the xml data with ${body}, it doest work like below.

.to("http://mydomain:8080/my-bin/myProgram.pgm?xmlData=${body}")

Am i doing it right?? or some data type has to be defined? please help me out..


Solution

  • Quick solution:

    change it to:

    .recipientList(simple("http://mydomain:8080/my-bin/myProgram.pgm?xmlData=${body}))
    

    Good solution:

    change myProgram.pgm to accept XML data sent by POST