【发布时间】:2019-06-29 01:18:30
【问题描述】:
我有一个这样的网络服务:
<camelContext id="camel-CallAPI" xmlns="http://camel.apache.org/schema/blueprint" >
<!--Web service starts working -->
<restConfiguration bindingMode="auto" component="restlet" host="localhost" port="8889"/>
<rest path="/check">
<post uri="/version" consumes="application/json" produces="application/json">
<to uri="direct:first"/>
</post>
</rest>
<route>
<from uri="direct:first"/>
<setHeader headerName="Content-Type" id="header_contentType">
<constant>application/json</constant>
</setHeader>
<log message="after set header :: ${body}"/>
<to uri="http4://..."/>
<convertBodyTo type="java.lang.String"/>
<log message="the result of the testCheckLastVersion :: ${body}"/>
我在邮递员的帮助下将 json 内容发送到此 Web 服务,并且我需要我的 Web 服务将该 json 发送到在 direct:first 中提到的另一个 API。 但是当我在邮递员中调用我的网络服务时,发生了错误:
org.apache.camel.InvalidPayloadException:没有可用类型的主体:java.io.InputStream 但具有值:{version=apk.1.10.0} 类型:java.util.LinkedHashMap on:Message[ID-localhost -localdomain-1549348033140-14-4]。原因:没有类型转换器可用于从类型:java.util.LinkedHashMap 转换为所需类型:java.io.InputStream,值为 {version=apk.1.10.0}。
谁能帮我解决这个问题?
【问题讨论】:
-
您在 Camel 路线的哪个位置看到该异常,Camel 也记录了该异常。还请告诉我们您使用的 Camel 版本。
-
当我调用 API (
) 时发生异常,我的骆驼版本是 2.21 -
那是因为您首先记录消息正文并基于其流式传输,请参阅此常见问题解答:camel.apache.org/why-is-my-message-body-empty.html
-
我试过没有任何日志,但仍然有同样的问题!
-
请尝试将以下属性添加到您的camelContext或您的路线元素
streamCache="true"。
标签: rest post apache-camel postman