Search code examples
javaspringapache-camelrestlet

Not able to hit external HTTP service via Apache Camel


I have a camel route similar to:

<camel:routeContext xmlns="http://camel.apache.org/schema/spring">
<route>
    <from uri="restlet:/v1/authentication/initiate?restletMethod=post&amp;restletBinding=#queryStringToHeadersRestletBinding"/>
    <to uri="http://xx.xx.xx.xx:20015/login"></to>
</route>

Now, after receiving the request from restlet, the camel processor instead of going to http://xx.xx.xx.xx:20015/login tries to hit http://localhost/v1/authentication/initiate which does not exist and thus I get 404 HTTPOperation failed like:

    Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://localhost/v1/authentication/initiate with statusCode: 404
    at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:228) ~[camel-http-2.12.4.jar:2.12.4]
    at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:156) ~[camel-http-2.12.4.jar:2.12.4]
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[camel-core-2.12.4.jar:2.12.4]

I am able to use the routes at other places successfully. But don't know why it is not hitting the intended destination url in this route definition. Please help.


Solution

  • Remove the CamelHTTP headers which the restlet may cause noise when calling the HTTP endpoint.

    See this FAQ: http://camel.apache.org/how-to-remove-the-http-protocol-headers-in-the-camel-message.html