类型转换异常:Apache Camel 和 CXF [英] TypeConversion Exception : Apache Camel and CXF

查看:42
本文介绍了类型转换异常:Apache Camel 和 CXF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 CXF Restful Web 服务与 Apache Camel 集成.当我向 Web 服务发送请求时出现以下异常:

I am trying to integrate CXF restful web services with Apache Camel. I am getting the following exception when I send a request to my web service:

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 的一部分以供审查:

I am pasting a section of my config xml for review:

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

推荐答案

解决了所有错误..实际上问题不是当我的 cxf 服务器被击中时,而是当交换处于to"时部分...我不得不在 from 和 to 之间添加一个处理器并覆盖所有 CamelHttpUri 、 CamelHttpMethod 等......以使其工作.

solved all the errors.. actually the problem was not when my cxf server was getting hit, it comes out to be when the exchange was in the "to" part... i had to add a processor in between from and to and override all the CamelHttpUri , CamelHttpMethod etc .... to make it work.

<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" />

这篇关于类型转换异常:Apache Camel 和 CXF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆