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

标签 java spring apache-camel restlet

我有一条类似于以下的 Camel 路线:

<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,如下所示:

    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。 请帮忙。

最佳答案

删除 CamelHTTP header ,reSTLet 在调用 HTTP 端点时可能会产生噪音。

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

关于java - 无法通过 Apache Camel 访问外部 HTTP 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41746598/

相关文章:

java - href 元素的 Xpath

java - 如何通过 HTTP 将 UTF-8 字符作为字符串发送

java - 使用嵌入式 Jetty 进行身份验证

java - 模式验证错误的自定义映射器

java - 正则表达式忽略已声明的变量初始化

java - 根上下文上的 JAX-RS 应用程序 - 怎么做?

spring - 如何有条件地不在 spring boot 中创建 bean?

Spring Security 与 REST 服务的 SAML token

java - 在 Apache Camel 中使用 session 和 Cookie

java - 每个端点的 Camel 拦截器,而不是每个 CamelContext