Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6119693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:34:58+00:00 2026-05-23T15:34:58+00:00

In an Apache Camel route, I want to take several headers and compose them

  • 0

In an Apache Camel route, I want to take several headers and compose them into an HTTP query string in a safe way. The only examples I’ve found either use constant(), which isn’t useful for building dynamic query strings, or they use simple() which doesn’t offer URL escaping.

For example, take the following snippet right from HTTP component’s documentation:

   from("direct:start")
      .setHeader(Exchange.HTTP_QUERY, constant("order=123&detail=short"))
      .to("http://oldhost");

This is 90% of the way there, but what if you don’t always want order id 123? We’d like to be able to substitute a header value here. So, the next logical version of this is to switch to simple:

   from("direct:start")
    .setHeader(Exchange.HTTP_QUERY, simple("order=${header.orderId}&detail=short"))
    .to("http://oldhost");

But this has the major issue of not being URL encoded. This means that a space (or any reserved character) in header.orderId results in an exception thrown by the HTTP component for an invalid query string.

So the only way that’s left is to use JavaScript, which is very verbose for something like this, or to write a custom processor. It seems like this should be something that’s built-in, so I’m asking here to see if I’m missing an obvious/normal way to do what I’m
looking for here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:34:59+00:00Added an answer on May 23, 2026 at 3:34 pm

    see http://camel.465427.n5.nabble.com/URI-Escaping-in-HTTP-and-other-Producers-td4427457.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the Camel Example camel-example-spring-jms (also at http://activemq.apache.org/camel/tutorial-jmsremoting.html ). However, when
Using Apache's commons-httpclient for Java, what's the best way to add query parameters to
I want to run a simple Apache Camel example that copies files from one
I saw in the apache camel source code that public class DefaultCamelContext extends ServiceSupport
On Apache/PHP sites if I want to put a senstive file within my website
I just want my apache to register some of my predefined environment so that
I'm having trouble getting the Apache Camel plugin to run in grails-1.1.1. Here's the
I've seen BASIC and Apache Camel DSLs in Scala, and they're just fantastic. Any
I have cxf webservice and I want to call that by camel. could anybody
I am working on a POC with Apache Camel, I have to expose a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.