【发布时间】:2012-04-20 12:59:59
【问题描述】:
我正在尝试将 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>
【问题讨论】:
-
尝试在你的 spring 配置中添加它。
-
我已经在 myconfig xml 中有这个
-
您使用的是什么版本的 Camel 和 CXF?来自 CXF 的消息似乎为空(null),因此类型转换失败。您将什么发布到您的 RS 服务?
-
Camel 版本 -2.9.0 CXF 版本 2.5.2.. 这是空的,因为我没有向我的服务器发布任何内容。理想情况下,我需要向我的服务器发布一个 json,它应该自动转换为 POJO(这发生在我的配置中只有 cxf 而不是 camel 时)。现在,如果我发布 json,它会给出相同的错误,除了 null 它显示 POJO 名称。另外请告诉我,当我用一个简单的 rest url 访问我的服务器时,实际上被击中的是什么.. jaxrs:server tag 或 camelcxf:server tag??
-
当我通过 get 方法访问我的服务器时也会出现问题,假设我有服务器服务类 Demo,它映射到 url“localhost:8080/MyProject/rest/demo”,它需要一个用户名(字符串)作为获取参数...所以当我使用 url :localhost:8080/MyProject/rest/demo?username=Sikorski 访问它时,它给了我以下错误:java.lang.IllegalArgumentException: Invalid uri: /MyProject/rest/demo/demo.如果您要转发/桥接 http 端点,请在端点“\\{google.com}”上启用 bridgeEndpoint 选项...
标签: java rest cxf apache-camel