camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kraythe ." <>
Subject Re: How could I post a Map to my restful api by camel?
Date Wed, 04 Jun 2014 14:55:20 GMT
All params passed in a HTTP Query string are converted to headers in the
exchange. And of course the actual URL the user used would be available in
a header as well. So you don't even need to go to the extent you have here.
Most of the time you are actually trying to remove headers or transform
them so you don't confuse a remote service. Your code should be:

  .setHeader("app param x", constant("myconstant"))
  .setHeader(Exchange.HTTP_PATH, simple(/* expression to build path from
  .setHeader(Exchange.HTTP_QUERY, simple(/* expression to build new query
from headers */)
  .to("http4:// ....");

In this manner all can be done in the DSL.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **

On Thu, May 29, 2014 at 1:13 AM, sleeper <> wrote:

> I have a web app,which provides some restful api,some of them have been
> marked as @POST.
> In my camel router,I wanna post a Map params to the restful api,how could I
> do it?
> Exchange res = template.request("direct:///start", new Processor() {
>         public void process(Exchange exchange) throws Exception {
>                 exchange.getIn().setHeader("to", targetApp);//targetApp is
> my restful api
> uri
>                 exchange.getOut().setBody(params);//params is a
> java.util.Map type
>         }
> });
> here is the problem
> 1)when I set the map type into the body,My rest can not get the request.
> 2)when I turn the map into a String type,My rest get the request,but where
> is my params data gone??
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message