【问题标题】:Not able to hit external HTTP service via Apache Camel无法通过 Apache Camel 访问外部 HTTP 服务
【发布时间】:2017-01-19 16:15:20
【问题描述】:

我的骆驼路线类似于:

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

我可以成功使用其他地方的路线。但不知道为什么它没有在此路由定义中达到预期的目标 url。 请帮忙。

【问题讨论】:

  • 您之前是否在路由中设置了Exchange.HTTP_URI 标头?或许这就是 Restlet 正在做的事情?这将覆盖路由中给出的 uri 的值
  • 移除在调用 HTTP 端点时,restlet 可能会产生噪音的 CamelHTTP 标头。请参阅此常见问题解答:camel.apache.org/…
  • 是的,CamelHTTPHeader 导致了指向 restlet url 的问题。删除标题工作:&lt;removeHeaders pattern="CamelHttp*" excludePattern="CamelHttpMethod" /&gt; 谢谢大家!

标签: java spring apache-camel restlet


【解决方案1】:

移除restlet在调用HTTP端点时可能产生噪音的CamelHTTP标头。

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

【讨论】:

    猜你喜欢
    • 2015-03-30
    • 2017-10-02
    • 1970-01-01
    • 2020-03-08
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 2017-05-10
    • 2019-01-09
    相关资源
    最近更新 更多