Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-656

...

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

Name

Type

Description

HttpProducer.QUERY

String

URI parameters. Will override existing URI parameters set directly on the endpoint. 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.

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.

Response code

Camel will handle according to the http response code:

  • 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

Calling using GET or POST

...

Code Block
xml
xml
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
  <route>
    <from uri="direct:start"/>
    <setHeader headerName="http.requestMethod">
        <constant>POST</constant>
    </setHeader>
    <to uri="http://www.google.com"/>
    <to uri="mock:results"/>
  </route>
</camelContext>

Setting charset to send data

If you are using POST to send data you can configure the charset using the Exchange property:

Code Block

   exchange.setProperty(Exchange.CHARSET_NAME, "iso-8859-1");

Or the HttpClient options: httpClient.contentCharset=iso-8859-1

Sample with scheduled poll

...

In the header value above notice that it should not be prefixed with ? and you can separate parameters as usual with the & char.

Getting the Response Code

You can get the http response code from the http component by getting the value from out message header with HttpProducer.HTTP_RESPONSE_CODE.

...

If you need more control over the http producer you should use the HttpComponent where you can set various classes to give you custom behavior. // TODO: Sample how to do this

Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also

...