camel中发布webservice的问题

camel自带的例子:camel-example-cxf-tomcat

运行OK。

但是把WebService接口方法的返回值由对象改为List,
当然,实现中也调整为返回List。

但执行错误:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: org.apache.camel.example.cxf.incident.OutputReportIncident cannot be cast to java.util.List

同样的,含有List返回值的WebService,如果使用CXF发布和实现,执行正常。
<jaxws:endpoint id="foo" implementorClass="my.FooImpl" address="/foo" />

但是调整为camel发布的方式:
<bean id="fooImpl" class="my.FooImpl"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="cxf:/foo?serviceClass=my.IFoo"/>
    <to uri="bean:fooImpl"/>
  </route>
</camelContext>

就会出现cannot be cast to java.util.List的错误。
如果把List返回方式改为普通对象,就执行正常。

有人帮看一下吗?
多谢!

我试了下,你这个错误不是camel,也不是cxf的,而是jaxb的错误。jaxb解析的时候,是需要被解析对象添加了jaxb的注解:(@XmlRootElement)
如果你想返回List,可以把list的值放到对象中,然后通过对象获取list列表。
这是我的测试代码,如下:
[code="java"]
OutputReportIncident output = new OutputReportIncident();
output.setCode("OK;");
List result = new ArrayList();
result.add(output);

    JAXBContext context;
    try {
        context = JAXBContext.newInstance(ArrayList.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "GBK");
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        marshaller.marshal(result, new File("d:/test.xml"));
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

[/code]
这样的代码运行错误信息为:
unable to marshal type "java.util.ArrayList" as an element because it is missing an @XmlRootElement annotation]

而cxf是封装了这样的错误

问题可解决了?camel发布webservice是使用cxf组件,那么cxf肯定是支持list的,可能是配置问题。
如果未解决,我帮你把camel这个例子跑一遍看看

<camle-cxf:cxfEndpoint id="calculator" address="/calculator" serviceClass="com.cecdat.camel.study.webservice.EIPWebService" />

<bean id="processor" class="com.cecdat.camel.study.webservice.EIPWebServiceImpl" />

<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="cxf:bean:calculator"/>
        <setHeader name="CamelBeanMethodName">
            <simple>${in.header.operationName}</simple>
        </setHeader>
        <to uri="bean:processor" />
    </route>
</camelContext>