【发布时间】:2017-01-19 16:15:20
【问题描述】:
我的骆驼路线类似于:
<camel:routeContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="restlet:/v1/authentication/initiate?restletMethod=post&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 的问题。删除标题工作:
<removeHeaders pattern="CamelHttp*" excludePattern="CamelHttpMethod" />谢谢大家!
标签: java spring apache-camel restlet