Apache Camel调用SOAP服务强制转换问题

Apache Camel调用SOAP服务强制转换问题,soap,apache-camel,redhat,Soap,Apache Camel,Redhat,我是Apache Camel的新手,我使用的是Red Hat CodeReady Studio 12.16.0.GA。我想调用soapweb服务。我用过这个例子 这是我的camel上下文文件 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel-cxf="http://camel.apache.org/schema/cxf" xmlns:xsi=&

我是Apache Camel的新手,我使用的是Red Hat CodeReady Studio 12.16.0.GA。我想调用soapweb服务。我用过这个例子

这是我的camel上下文文件

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="        http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd        http://camel.apache.org/schema/spring       https://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
    <bean class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor" id="gZipInInterceptor"/>
    <bean
        class="org.apache.cxf.transport.common.gzip.GZIPOutInterceptor" id="gZipOutInterceptor"/>
    <camel-cxf:cxfEndpoint
        address="http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso"
        id="fullCountryInfoResponseClient" serviceClass="org.oorsprong.websamples_countryinfo.CountryInfoServiceSoapType">
        <camel-cxf:inInterceptors>
            <ref bean="gZipInInterceptor"/>
        </camel-cxf:inInterceptors>
        <camel-cxf:outInterceptors>
            <ref bean="gZipOutInterceptor"/>
        </camel-cxf:outInterceptors>
    </camel-cxf:cxfEndpoint>
    <bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="bean-66d2672d-c6c0-4984-bc31-90bc30bfaaef"/>
    <camelContext id="camel"
        xmlns="http://camel.apache.org/schema/spring" xmlns:order="http://fabric8.com/examples/order/v7">
        <route id="simple-route">
            <from id="_to2" uri="timer:timerName?delay=0&amp;repeatCount=1"/>
            <setBody id="_setBody2">
                <constant>"US"</constant>
            </setBody>
            <bean beanType="com.example.GetFullCountryInfoBuilder"
                id="_bean1" method="getFullCountryInfo"/>
            <setHeader headerName="operationNamespace" id="_setHeader1">
                <constant>http://www.oorsprong.org/websamples.countryinfo</constant>
            </setHeader>
            <setHeader headerName="operationName" id="_setHeader2">
                <constant>FullCountryInfo</constant>
            </setHeader>
            <to id="_to1" uri="cxf:bean:fullCountryInfoResponseClient"/>
            <bean beanType="com.example.GetFullCountryInfoBuilder"
                id="_bean2" method="getFullCountryInfoOutput"/>
            <log id="_log1" message=">>>${body}"/>
        </route>
    </camelContext>
</beans>
仍然获取错误
org.apache.cxf.interceptor.Fault:org.oorsprong.websamples.FullCountryInfo无法转换为java.lang.String
看起来CXF不处理FullCountryInfo对象,但String和Camel尝试将其转换。
当我将getFullCountryInfo的return改为String时,这个异常会消失,但会出现另外两个异常

Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.oorsprong.websamples.FullCountryInfoResponse but has value: [org.oorsprong.websamples.TCountryInfo@3c5110df] of type: org.apache.cxf.message.MessageContentsList on: Message[]. 

所以,CXF的输入不是示例中描述的对象,而是字符串。 CXF的输出是org.apache.CXF.message.MessageContentsList,您必须将其转换为字符串以记录它。在本例中,我使用了getFullCountryInfoOutput bean

Caused by: org.apache.camel.InvalidPayloadException: No body available of type: org.oorsprong.websamples.FullCountryInfoResponse but has value: [org.oorsprong.websamples.TCountryInfo@3c5110df] of type: org.apache.cxf.message.MessageContentsList on: Message[]. 
Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.oorsprong.websamples.FullCountryInfoResponse with value [org.oorsprong.websamples.TCountryInfo@3c5110df]] Caused by: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.oorsprong.websamples.FullCountryInfoResponse with value [org.oorsprong.websamples.TCountryInfo@3c5110df]. Exchange[ID-sw70-1599555257341-0-1].