How to proxy HTTP requests in Camel?

Solution In Progress - Updated -

Environment

  • Fuse Mediation Route 2.x
  • JBoss Fuse 6.0

Issue

Can you please provide an example on how to configure HTTP Proxying in Camel?

Resolution

HTTP Proxying in Camel is documented in chapter "Proxying HTTP" in the JBoss Fuse 6.0 "Web Services and Routing with Camel CXF" Guide.

If you look for a ready-to-use demo, please check out the demo at
https://github.com/tmielke/fuse-demos/tree/master/Camel/Camel-HTTP-Proxy.

Simply follow the instruction in the provided readme.md.

This demo uses the following simple route definition to proxy HTTP requests from http://localhost:9000/weather to http://weather.yahoo.com/united-states.

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route id="camel-http-proxy">
    <from uri="jetty://http://localhost:9000/weather?matchOnUriPrefix=true"/>
    <to uri="http://weather.yahoo.com/united-states?bridgeEndpoint=true&amp;throwExceptionOnFailure=false" />
    <to uri="log:MyLogger?level=INFO&amp;showAll=true" />
  </route>
</camelContext>

Its important to use matchOnUriPrefix=true and bridgeEndpoint=true.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.