TypeConversion例外:Apache的骆驼和CXF(TypeConversion Exce

2019-06-23 19:10发布

我试图与Apache骆驼整合CXF RESTful Web服务。 我得到以下异常时,我将请求发送到我的web服务:

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: java.io.InputStream with value [null]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:147)
    at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)
    ... 68 more

我贴我的配置XML进行审查的一部分:

<jaxrs:server id="restContainer" address="/" staticSubresourceResolution="true">

<jaxrs:serviceBeans>
    <ref bean="FooBar"/>
</jaxrs:serviceBeans>

<jaxrs:providers>
    <bean class="org.apache.cxf.jaxrs.provider.JSONProvider">
    <property name="dropRootElement" value="true"/>
    <property name="supportUnwrapped" value="true"/>
</jaxrs:providers>

<camelcxf:rsServer id="rsServer" address="http://localhost:port/MyApplication/rest/foobar" serviceClass="com.camel.example.FooBar"/>

<camel:camelContext id="camelContext-1">
    <camel:route>
        <camel:from uri="cxfrs:bean:rsServer"/>
        <camel:to uri="http://www.google.com"/>
    </camel:route>
</camel:camelContext> 

Answer 1:

解决了..其实这个问题并没有当我的CXF服务器被击中的所有错误,它出来是当交换是在“到”部分......我不得不往返于和覆盖之间增加一个处理器所有CamelHttpUri,CamelHttpMethod等....,使其工作。

<camelcxf:rsServer id="rsServer" address="http://localhost:port/MyApplication/rest/foobar serviceClass="com.camel.example.FooBar" />  <camel:camelContext id="camelContext-1">  <camel:route>  
<camel:from uri="cxfrs:bean:rsServer" />  
<camel:process ref="customInProcessor" />
<camel:to uri="http://www.google.com" /> 
 </camel:route>
  </camel:camelContext> 

<bean id="customInProcessor" class="com.camel.MyInProcessor" />


文章来源: TypeConversion Exception : Apache Camel and CXF