...
Name | Default Value | Description |
---|---|---|
throwException throwExceptionOnFailure | true | Camel 2.0: Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardles of the HTTP status code. |
httpBindingRef | null | Reference to a |
username | null | Username for basic http authentication. |
password | null | Password for basic http authentication. |
httpClientConfigurerRef | null | Reference to a |
httpClient.XXX | null | Setting options on the HttpClientParams. For instance httpClient.soTimeout(5000) will set the SO_TIMEOUT to 5 seconds. |
...
- response code is between 100..299 then Camel regard it as a success response
- response code is between 300..399 then Camel regard it as a redirection was returned and will throw a HttpOperationFailedException with the information
- response code is 400+ then Camel regard it as a external server failure and will throw a HttpOperationFailedException with the information
Tip | ||
---|---|---|
| ||
The option |
...
Code Block | ||||
---|---|---|---|---|
| ||||
Exchange exchange = template.send("http://www.google.com/search", new Processor() { public void process(Exchange exchange) throws Exception { exchange.getIn().setHeader(HttpProducer.QUERY, constant("hl=en&q=activemq")); } }); Message out = exchange.getOut(); int responseCode = out.getHeader(HttpProducer.HTTP_RESPONSE_CODE, Integer.class); |
Using
...
throwExceptionOnFailure=false
to get any response back
Available as of Camel 2.0
In the route below we want to route a message that we enrich with data returned from a remote HTTP call. As we want any response from the remote server we set the throwException
throwExceptionOnFailure
option to false so we get any response in the AggregationStrategy
. As the code is based on an unit test that simulates a http status code 404, there is some assertion code etc.
...