On Thu, Jul 28, 2011 at 4:43 AM, daveharris <[email protected]> wrote: > Hi, > I am writing a route which sends a HTTP GET request with a bunch of request > parameters. > > Looking at the documentation, the way to do this is via: > from("direct:start") > .setHeader(Exchange.HTTP_QUERY, constant("order=123&detail=short")) > .to("http://oldhost"); > > This is fine, but I was hoping for a cleaner way of doing it -where I don't > have to handle escaping and &s. > I've been talking to @Blair and he suggested passing in a map to > Exchange.HTTP_QUERY but that didn't work. > > My route defintion turns into a somewhat ugly-looking: > from("...") > .setHeader(Exchange.HTTP_QUERY, > constant("app=").append(header(APPLICATION)) > .append("&from=").append(header(FROM)) > .append("&to=").append(header(TO)) > .append("&msg=").append(header(MESSAGE)) > ) > .to("http://localhost/service") > > To produce a HTTP get request of > http://localhost:3000/service?app=test&from=a&to=b&msg=hi > > Is this is the only/best way to do it? Just checking that there isn't some > shortcut which I can use instead. >
You can use the recipient list eip http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html Then you can use the simple language to refer to the headers in the uri .recipientList().simple("http://localhost:3000/service?app={{header.APPLICATION}}&from={{header.FROM}}$...") > The above *works* perfectly well, just being pedantic... > > Thanks, > Dave > > -- > View this message in context: > http://camel.465427.n5.nabble.com/camel-http-Multiple-Request-Paramaters-tp4641050p4641050.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
