【发布时间】:2013-11-12 13:46:26
【问题描述】:
我有一个 RESTful Web 服务,我想将它与 Camel-Route 中的内容丰富器一起使用。 请参阅此类似代码:
from("direct:in") // Here comes XML
.to("validator:something.xsd") // validate it
.unmarshal("something-jaxb") // put it into a POJO
.setHeader(Exchange.HTTP_URI, simple("http://localhost:12345/restws/${header.foo}")) // Create the dynamic URI with simple
.setHeader(Exchange.HTTP_METHOD, constant("GET")) // set the HTTP-Method to use
.enrich("http://dummy", new MyAggregator()) // fetch some Information from a Restful Webservice
.to("direct:out"); // send the Message to another route
如果我运行它,我会收到以下错误:
No type converter available to convert from type: de.my.Class to the required type: java.io.InputStream with value de.my.Class@620ee765.
在我看来,他试图将 Exchange 的主体发送到 http-Endpoint,尽管我将 HTTP-Method 设置为 GET。我已阅读文档 (https://camel.apache.org/http.html) 和下面的 使用 GET 或 POST 调用 它描述了选择方法的算法首先查看标题(1. 使用标题中提供的方法)。
我找到了一些解决方法,其中描述了如何将正文移动到 Exchange 属性并在 Webservice-Call 之后再次将其移回,但这不可能......
编辑:
- 像 Claus Ibsen 提到的丰富不支持动态 uri。在示例中修复了这个问题!
【问题讨论】:
标签: java rest apache-camel