无法通过Apache Camel访问外部HTTP服务

时间:2017-01-19 16:15:20

标签: java spring apache-camel restlet

我的骆驼路线类似于:

<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>

现在,在收到来自restlet的请求之后,camel处理器而不是转到http://xx.xx.xx.xx:20015/login尝试点击不存在的http://localhost/v1/authentication/initiate,因此我得到404 HTTPOperation失败,如:

    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]

我能够成功使用其他地方的路线。但是不知道为什么它没有在这个路线定义中达到预期的目标网址。 请帮忙。

1 个答案:

答案 0 :(得分:1)

在调用HTTP端点时,删除重定时器可能导致噪声的CamelHTTP标头。

请参阅此常见问题解答:http://camel.apache.org/how-to-remove-the-http-protocol-headers-in-the-camel-message.html