微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从CXF端点调用Spring Integration应用程序

我正在使用Apache CXF Web服务和Spring Integration,现在我不怎么从CXF端点调用Spring Integration应用程序.

我有使用Apache Camel的经验,很容易解决这个问题.但是在Spring Integration中,我没有任何想法.

我的行代码是:

>在webservices-deFinition-beans.xml中:

<!-- Load CXF modules from cxf.jar -->
<import resource="classpath:meta-inf/cxf/cxf.xml"/>
<import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:meta-inf/cxf/cxf-servlet.xml"/>

<!--Exposing the HelloWorld service as a SOAP service -->
<bean id="jaxbBean"
      class="org.apache.cxf.jaxb.JAXBDataBinding"
      scope="prototype"/>

<bean id="jaxws-and-aegis-service-factory"
      class="org.apache.cxf.jaxws.support.JaxWsServicefactorybean"
      scope="prototype">
    <property name="dataBinding" ref="jaxbBean"/>
    <property name="serviceConfigurations">
    <list>
        <bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
        <bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration"/>
        <bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
    </list>
</property>
</bean>

<jaxws:endpoint id="helloWorld"
            serviceName="HelloWorldService"
            implementorClass="com.datys.cxf.HelloWorldService"
            address="/HelloWorld">
    <jaxws:serviceFactory>
        <ref bean="jaxws-and-aegis-service-factory"/>
    </jaxws:serviceFactory>
</jaxws:endpoint> 

>在service-deFinition-beans.xml中:

<gateway id="HelloWorldService" 
         default-request-channel="requestStrings"
         default-reply-channel="replyStrings"             
         service-interface="com.datys.cxf.HelloWorldService">
    <method name="sayHello"/>
</gateway>

<channel id="requestStrings"/>
<channel id="replyStrings"/> 

<!--<channel id="filesOut"/>-->
<service-activator input-channel="requestStrings"
                   output-channel="filesOut"
                   ref="handler" method="handleString"/>

<file:outbound-channel-adapter id="filesOut" 
                               directory="file:D:/OUTPUT"/>

<beans:bean id="handler" class="org.springframework.integration.samples.filecopy.Handler"/>

但是,当我使用客户端Web服务部署和调用Web服务时,返回此错误

Exception in thread "main" javax.xml.ws.soap.soAPFaultException: Could not instantiate service     class com.datys.cxf.HelloWorldService because it is an interface.
at com.sun.xml.internal.ws.fault.soAP11Fault.getProtocolException(SOAP11Fault.java:171)
at com.sun.xml.internal.ws.fault.soAPFaultBuilder.createException(SOAPFaultBuilder.java:94)
at com.sun.xml.internal.ws.client.sei.SyncmethodHandler.invoke(SyncmethodHandler.java:240)
at com.sun.xml.internal.ws.client.sei.SyncmethodHandler.invoke(SyncmethodHandler.java:210)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103)
at $Proxy29.sayHello(UnkNown Source)
最佳答案
可能最简单的选择是配置< gateway>.这样,您就可以提供可以注入到端点并调用它以启动消息流的任何接口.在幕后,该接口的实现方式与Spring中其他“ Proxyfactorybean”的实现方式相同(例如,通过RMI,httpinvoker等进行远程处理).

这是参考手册中的相关部分:
http://static.springsource.org/spring-integration/docs/2.1.x/reference/htmlsingle/#gateway-proxy

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐