NoTypeConversionAvailableException:骆驼休息DSL

问题描述 投票:0回答:1

我有这样一个Web服务:

<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发送到已经直接提到另一个API:第一。但是当我把我的Web服务在邮递员的错误是发生的事情:

org.apache.camel.InvalidPayloadException:没有可用的类型的主体:java.io.InputStream中但是具有值:类型{版本= apk.1.10.0}:java.util.LinkedHashMap中于:消息[ID-本地主机 - localdomain- 1549348033140-14-4。没有可从类型转换类型转换器:由造成java.util.LinkedHashMap中所要求的类型:值为{版本= apk.1.10.0}的java.io.InputStream。

谁能帮我这个?

rest post apache-camel postman
1个回答
2
投票

我找到了解决办法,异常造成的,因为我设置camelContext这是不适合这里的bindingMode =“自动”,通过消除,问题解决了。

<camelContext id="camel-CallAPI" xmlns="http://camel.apache.org/schema/blueprint" >
             <!--Web service starts working -->
           <restConfiguration component="restlet" host="localhost" port="8889"/>
           <rest path="/say">
              <post uri="/hi" consumes="application/json" produces="application/json">
                <to uri="direct:first"/>
              </post> 
           </rest>         
           <route>         
              <from uri="direct:first"/>
                 <setHeader headerName="Content-Type" id="_setHeader2">
                     <constant>application/json</constant>
                 </setHeader>
           <to uri="http4://..."/>
           <convertBodyTo type="java.lang.String"/>
           <log message="the result of the testCheckLastVersion :: ${body}"/>  
          </route> 

</camelContext>
© www.soinside.com 2019 - 2024. All rights reserved.