2012-04-20 138 views
0

我正在嘗試將CXF寧靜的Web服務與Apache Camel集成。我得到以下異常時,我將請求發送到我的web服務:TypeConversion例外:Apache Camel和CXF

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> 
+0

嘗試在你的spring配置文件中加入這個。 2012-04-21 20:42:00

+0

我已經在myconfig xml中使用了這個。 – Sikorski 2012-04-22 06:08:18

+0

您使用的是哪種版本的Camel和CXF?看起來來自CXF的消息是空的(空),因此類型轉換失敗。你在你的RS服務上發佈了什麼? – 2012-04-22 06:45:06

回答

2

解決所有的錯誤..其實問題不是當我的cxf服務器被擊中時,它出現在交換機處於「to」部分時...... 我必須在from和to之間添加一個處理器,並覆蓋所有的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" />