web-services - 如何在 Mule Flow 中使用 SOAP Web 服务?

标签 web-services soap jax-ws cxf mule

我从 Mule flows 开始,我已经看到了这个页面 http://www.mulesoft.org/documentation/display/MULE3CONCEPTS/Using+Mule+with+Web+Serviceshttp://www.mulesoft.org/documentation/display/MULEWS/Consuming+SOAP+Web+Services+in+Mule这个oe也是。他们帮不上什么忙。目前,我有一个简单的 mule 流,如下所示。

流定义

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1"
    xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
    <flow name="EchoFlow" doc:name="EchoFlow">
        <http:inbound-endpoint exchange-pattern="request-response"
            host="localhost" port="8081" path="service/echoflow" doc:name="HTTP" />
        <cxf:jaxws-client operation="" serviceClass="com.myapp.demo.ServiceAImplService" 
            doc:name="SOAP"/>
        <outbound-endpoint address="http://localhost:8080/ServiceA/services/" doc:name="Generic"/>
    </flow>
</mule>

我正在使用 Mule Studio。有一个 HTTP 入站端点需要响应。我尝试配置一个将调用实际 Web 服务的 jax-ws 客户端。该服务的 WSDL 是:

wsdl文件

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="ServiceAImplService" targetNamespace="http://service.demo.myapp.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.demo.myapp.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<import namespace="http://service.demo.myapp.com/" schemaLocation="http://localhost:8080/ServiceA/services/ServiceAImplPort?xsd=serviceaimpl_schema1.xsd"/>
</schema>
  </wsdl:types>
  <wsdl:message name="helloResponse">
    <wsdl:part element="tns:helloResponse" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="hello">
    <wsdl:part element="tns:hello" name="parameters">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IServiceA">
    <wsdl:operation name="hello">
      <wsdl:input message="tns:hello" name="hello">
    </wsdl:input>
      <wsdl:output message="tns:helloResponse" name="helloResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ServiceAImplServiceSoapBinding" type="tns:IServiceA">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="hello">
      <soap:operation soapAction="urn:Hello" style="document"/>
      <wsdl:input name="hello">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="helloResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ServiceAImplService">
    <wsdl:port binding="tns:ServiceAImplServiceSoapBinding" name="ServiceAImplPort">
      <soap:address location="http://localhost:8080/ServiceA/services/ServiceAImplPort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

如您所见,我不太确定如何配置 jax-ws 客户端。那么,在此流程中我究竟如何使用 SOAP Web 服务。


我的第二个问题:如何转换负载以从一个网络服务调用另一个网络服务(均为 SOAP)。流程是什么?


最后,我如何合并有效负载?比如说,我有三个并行调用的 Web 服务,它们的响应都一起返回。如何合并有效负载以便我可以在另一个服务中读取它(在合并来自多个并行调用的服务的响应之后)?



什么是等价的实现

       <pattern:web-service-proxy name="ex-proxy"
        inboundAddress="http://localhost:8081/xxx"
        outboundAddress="http://xx.xx.com/XXX_WS/xxxWService.asmx" /> 

使用 CXF 代理服务/客户端?这让我想到另一个问题,何时使用 CXF-service 以及何时使用 CXF-client?最后,是否有 Mule Flow Orchestration 的详细文档或示例/教程?

最佳答案

尝试使用 CXF 代理(服务和客户端)。在这种情况下,您会将原始 XML 放入流中。当然,如果需要,您可以将其反序列化为 java,例如通过 XML 到对象转换器 (XStream)。

http://www.mulesoft.org/documentation/display/MULE3USER/Proxying+Web+Services+with+CXF

从那里开始,有几种方法可以在中间转换有效载荷。要么通过 java(如上所述)并转换 java 层对象,要么编写执行转换的 XSLT 表。或者使用 Java 和/或 Mule 提供的其他工具(脚本、xpath 等)转换 XML。

您可能想再次详细解释聚合案例。您是要合并响应以备将来使用还是进行一次 Web 服务调用 -> 扇出 -> 聚合 -> 响应?

关于web-services - 如何在 Mule Flow 中使用 SOAP Web 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10056704/

相关文章:

java - Spring ClientInterceptor 在响应中显示空的 SOAP header

web-services - SOAP 请求的问题

javascript - 从 Javascript 连接到 SOAP Web 服务?

.net - 未定义的complexType 'http://schmeas.xmlsoap.org/soap/encoding/:Array'用作复杂类型限制的基础

java - 使用 WSDL 从 url 和身份验证实例化 JAX-WS 服务

java - Servlet 找不到库

xml - 元素或属性与 QName 生产不匹配

php - 网站需要永远加载然后我得到 "Uncaught SoapFault exception"

spring - JAX-WS 的注释端点位置

java - Jaxb2Marshaller 和原始类型