gpt4 book ai didi

java - 类型转换异常: Apache Camel and CXF

转载 作者:行者123 更新时间:2023-12-02 07:50:52 24 4
gpt4 key购买 nike

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

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>

最佳答案

解决了所有错误..实际上问题不是当我的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" />

关于java - 类型转换异常: Apache Camel and CXF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10246736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com