You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Carman <ja...@carmanconsulting.com> on 2010/06/25 22:41:47 UTC
Using BODY as HTTP Query String Parameter...
There is a web service at my company that returns XML documents, but
you have to query it using a query string. I want to send the single
parameter (an id) as the body of the incoming message and I want to
append that body value to the HTTP URL. So, I want something like:
http://my.service.url/service.cgi?id=${body}
Is that possible using the Java DSL?
Thanks,
James
p.s. Camel Rocks! I've downloaded the MEAP Camel in Action book and
I'm working my way through it. Very cool indeed!
Re: Using BODY as HTTP Query String Parameter...
Posted by Willem Jiang <wi...@gmail.com>.
Hi,
You could set the message with Exchange.HTTP_QUERY to let the http
producer pick up the query string dynamically.
Here is the example
from("direct:start").setHeader(Exchange.HTTP_QUERY).
simple("id=${body}")).to("http://XXXX");
Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang
James Carman wrote:
> There is a web service at my company that returns XML documents, but
> you have to query it using a query string. I want to send the single
> parameter (an id) as the body of the incoming message and I want to
> append that body value to the HTTP URL. So, I want something like:
>
> http://my.service.url/service.cgi?id=${body}
>
> Is that possible using the Java DSL?
>
> Thanks,
>
> James
>
> p.s. Camel Rocks! I've downloaded the MEAP Camel in Action book and
> I'm working my way through it. Very cool indeed!
>
Re: Using BODY as HTTP Query String Parameter...
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 25, 2010 at 10:41 PM, James Carman
<ja...@carmanconsulting.com> wrote:
> There is a web service at my company that returns XML documents, but
> you have to query it using a query string. I want to send the single
> parameter (an id) as the body of the incoming message and I want to
> append that body value to the HTTP URL. So, I want something like:
>
> http://my.service.url/service.cgi?id=${body}
>
> Is that possible using the Java DSL?
>
Yes you can for example use the setHeader to set the id header beforehand
.setHeader("id").simple("${body}").to("http://xxxx");
Or use the recipient list to construct a dynamic uri
http://camel.apache.org/recipient-list.html
.recipientList().simple("http://xxxx?id=${body}");
We use the Camel expression language, simple, to define the dynamic expression:
http://camel.apache.org/simple.html
> Thanks,
>
> James
>
> p.s. Camel Rocks! I've downloaded the MEAP Camel in Action book and
> I'm working my way through it. Very cool indeed!
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus