gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:53:16 25 4
gpt4 key购买 nike

我正在使用 Apache CXF 网络服务和 Spring Integration,但我现在不知道如何从您的 CXF 端点调用 Spring Integration 应用程序。

我有使用 Apache Camel 的经验,很容易解决这个问题......但在 Spring Integration 中我不知道......

我的行代码是:

  1. 在 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>
  2. 在服务定义 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"/>

但是当我使用 client-webservices 部署和调用 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)

最佳答案

可能最简单的选择是配置一个 。这允许您提供可以注入(inject)端点并调用它来启动消息流的任何接口(interface)。在幕后,该接口(interface)的实现方式与 Spring 中的其他“ProxyFactoryBean”实现方式相同(例如,通过 RMI、HttpInvoker 等进行远程处理)。

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

关于spring - 如何从 CXF 端点调用 Spring Integration 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10840114/

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