3

我从 Mule 流程开始,并看到了我已经看到这个页面http://www.mulesoft.org/documentation/display/MULE3CONCEPTS/Using+Mule+with+Web+Serviceshttp://www.mulesoft.org /documentation/display/MULEWS/Consuming+SOAP+Web+Services+in+Mule这个也是。他们没有多大帮助。目前,我有一个简单的 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>

我正在使用骡工作室。有一个 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 服务。


我的第二个问题:如何转换有效负载以从一个 Web 服务调用另一个 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 的详细文档或示例/教程?

4

3 回答 3

2

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

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

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

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

于 2012-04-08T22:32:49.040 回答
1

1) 通常,您应该使用“代理服务”而不是“JAX-WS”来使用远程 Web 服务。

2) 使用链接路由器在多个端点之间传递响应。

于 2012-04-08T13:06:31.033 回答
1

如果您有权访问 Web 服务的服务端点接口,则可以像这样在一个简单的 Java 组件中轻松使用 Web 服务:

public class CityServiceComponent {

    public String process(String input) {

        // list of cities
        StringBuilder output = new StringBuilder();

        // create service factory
        JaxWsProxyFactoryBean serviceFactory = new JaxWsProxyFactoryBean();
        // set service endpoint interface
        serviceFactory.setServiceClass(CityService.class);
        // set wsdl location
        serviceFactory.setAddress("http://localhost:8080/city-service-provider/CityService?wsdl");
        // init city service
        CityService cityService = (CityService) serviceFactory.create();

        // call city service and get all available cities
        List<City> cities = cityService.findAll();

        // build list of cities
        for (City city : cities) {

            output.append(city.toString());
            output.append("\n");
        }

        // forward output message
        return output.toString();

    }

}

希望这可以帮助...

于 2012-06-26T12:10:57.093 回答