...
Name | Default Value | Description |
---|---|---|
httpClient.XXX | null | Setting options on the HttpClientParams. For instance httpClient.soTimeout(5000) will set the SO_TIMEOUT to 5 seconds. |
Message Headers
Camel 1.x
Name | Type | Description |
---|---|---|
HttpProducer.CHARACTER_ENCODING | String | Camel 2.0: Character encoding. Is set on the IN message. |
HttpProducer.CONTENT_TYPE | String | Camel 2.0: Content type. Is set on the IN message. |
HttpProducer.HTTP_URI | String | Camel 1.5.1: URI to call. Will override existing URI set directly on the endpoint. Is set on the IN message. |
HttpProducer.HTTP_RESPONSE_CODE | int | The http response code from the external server. Is 200 for OK. Is set on the OUT message. |
HttpProducer.PATH QUERY | String | URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN message. |
Camel 2.0
Name | Type | Description |
---|---|---|
Constants.HTTP_URI | String | URI to call. Will override existing URI set directly on the endpoint. Is set on the IN message. |
Constants.HTTP_PATH | String | Request URI's path. Is set on the IN message. |
HttpProducer Constants.HTTP_QUERY | String | URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN message. |
Constants.HTTP_CHARACTER_ENCODING | String | Character encoding. Is set on the IN message. |
Constants.HTTP_CONTENT_TYPE | String | Content type. Is set on the IN message. |
Constants.HTTP_RESPONSE_CODE | int | The http response code from the external server. Is 200 for OK. Is set on the OUT message. |
Message Body
Camel will store the http response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message so headers is preserved during routing.
Additionally Camel will add the http response headers as well to the OUT message.
...
In the sample above Camel will call the http://newhost despite the endpoint is configured with http://oldhost.
And the same code in Camel 2.0:
Code Block |
---|
from("direct:start")
.setHeader(Constants.HTTP_URI, constant("http://newhost"))
.to("http://oldhost");
|
Where Constants is the class org.apache.camel.component.http.Constants
.
Configuring URI Parameters
...
Code Block |
---|
from("direct:start") .setHeader(org.apache.camel.component.http.HttpProducer.Constants.HTTP_QUERY, constant("order=123&detail=short")) .to("http://oldhost"); |
...
Code Block |
---|
from("direct:start") .setHeader(org.apache.camel.component.http.HttpMethods.Constants.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST)) .to("http://www.google.com") .to("mock:results"); |
The method can be written a bit shorter using the string constantconstants:
Code Block |
---|
.setHeader(org.apache.camel.component.http.HttpMethods.HTTP_METHOD"CamelHttpMethod", constant("POST")) |
And the equivalent spring sample:
Code Block | ||||
---|---|---|---|---|
| ||||
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:start"/> <setHeader headerName="http.requestMethodCamelHttpMethod"> <constant>POST</constant> </setHeader> <to uri="http://www.google.com"/> <to uri="mock:results"/> </route> </camelContext> |
...