1

现在,我有一个名为 ProcessPayment 的服务,它调用一个计费系统。正如我们在此处看到的,我想从我的支付服务调用另一个计费服务。PaymentService 的响应包含 3 个数据元素。BillingService 中需要其中之一。

如何在 Mule 中为两个或多个服务配置流?我尝试了各种排列,但它不起作用!

骡配置.xml

 <?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" 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" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:ognl="http://www.mulesoft.org/schema/mule/ognl" xmlns:servlet="http://www.mulesoft.org/schema/mule/servlet"
    xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
    xsi:schemaLocation="
        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
        http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.1/mule-pattern.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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
        http://www.mulesoft.org/schema/mule/ognl http://www.mulesoft.org/schema/mule/ognl/current/mule-ognl.xsd 
        http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">

    <!-- <flow name="parallelservices"> <all enableCorrelation="ALWAYS"> <cxf:proxy-service 
        wsdlLocation="classpath:billingservice.wsdl" bindingId="BillingServiceServiceSoapBinding" 
        port="BillingServicePort" service="BillingServiceService" payload="body" 
        namespace="http://com.myapp.demo/" /> </all> </flow> -->

    <flow name="initpayment">
        <inbound-endpoint address="http://localhost:8585/services/processpayment">
            <cxf:proxy-service wsdlLocation="classpath:processpaymentservice.wsdl"
                bindingId="ProcessPaymentServiceServiceSoapBinding" service="ProcessPaymentServiceService"
                payload="body" namespace="http://com.myapp.demo/" />
        </inbound-endpoint>
        <outbound-endpoint address="http://localhost:8081/BillingEntry/services/BillingServicePort">
            <!-- <flow-ref name="parallelservices" /> -->
            <cxf:proxy-client/>
        </outbound-endpoint>
    </flow>

</mule>

处理付款wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="ProcessPaymentServiceService" targetNamespace="http://processpayment.icp.sf/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://com.myapp.demo/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://processpayment.icp.sf/" schemaLocation="processpaymentservice_schema1.xsd"/>
</schema>
  </wsdl:types>
  <wsdl:message name="processPayment">
    <wsdl:part name="parameters" element="tns:processPayment">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="processPaymentResponse">
    <wsdl:part name="parameters" element="tns:processPaymentResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IProcessPayment">
    <wsdl:operation name="processPayment">
      <wsdl:input name="processPayment" message="tns:processPayment">
    </wsdl:input>
      <wsdl:output name="processPaymentResponse" message="tns:processPaymentResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ProcessPaymentServiceServiceSoapBinding" type="tns:IProcessPayment">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="processPayment">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="processPayment">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="processPaymentResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ProcessPaymentServiceService">
    <wsdl:port name="ProcessPaymentServicePort" binding="tns:ProcessPaymentServiceServiceSoapBinding">
      <soap:address location="http://localhost:8081/ProcessPayment/services/ProcessPaymentServicePort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

计费服务 wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="BillingServiceService" targetNamespace="http://com.myapp.demo2/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://billing.icp.sf/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <wsdl:types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://billing.icp.sf/" schemaLocation="billingservice_schema1.xsd"/>
</schema>
  </wsdl:types>
  <wsdl:message name="billingEntryResponse">
    <wsdl:part name="parameters" element="tns:billingEntryResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="billingEntry">
    <wsdl:part name="parameters" element="tns:billingEntry">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IBillingService">
    <wsdl:operation name="billingEntry">
      <wsdl:input name="billingEntry" message="tns:billingEntry">
    </wsdl:input>
      <wsdl:output name="billingEntryResponse" message="tns:billingEntryResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="BillingServiceServiceSoapBinding" type="tns:IBillingService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="billingEntry">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="billingEntry">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="billingEntryResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="BillingServiceService">
    <wsdl:port name="BillingServicePort" binding="tns:BillingServiceServiceSoapBinding">
      <soap:address location="http://localhost:8081/BillingEntry/services/BillingServicePort"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

即时问题

当我点击 Mule 配置入站 URL 时,我能够为 ProcessPayment 服务生成 wsdl。但它显示了修改后的值

   <import schemaLocation="".../>

   <wsdl:port><soap:address>*****</soap:address></wsdl:port>

使用此 URL,我无法在 SOAPui 上测试服务。但是当我点击服务原始地址而不是 Mule 入站地址时,我得到了我的实际服务。它也在 SOAP UI 中运行。

快速提问:

如何执行流程?简单地从浏览器或 SOAPui 调用入站 URL 行不通?

4

1 回答 1

2

在这里,我创建了一个示例,演示如何使用 CXF 代理执行 SOAP 信封级别操作。从那里我确信您可以扩展和构建您需要的任何东西。

请注意:

  • 不需要生成代码,实际上我必须删除您生成的类,否则它不起作用。这种带有 WSDL+XSD 的单一 XML 配置就足够了。
  • 我已经限定了 Mule 核心元素,以避免在默认命名空间中生成的元素 XSL-T 最终出现在 Mule 核心命名空间中。如果您将 XSL 片段外部化,则不需要这样做。
  • (人为的)示例公开了 processpaymentservice.wsdl。它获取 paymentType_req 的值,假装它是一个 IP 地址并使用它来调用http://www.webservicex.net/geoipservice.asmx。然后将地理定位的国家名称用作流程支付响应的 paymentType_res 元素的值(其他 2 个值是伪造的)。
  • 使用soapUI 4.5 和Mule 3.2.1 测试。

享受!

<mule:flow name="processPaymentServiceOrchestration">
    <http:inbound-endpoint address="http://localhost:8080/ppso"
        exchange-pattern="request-response">
        <cxf:proxy-service wsdlLocation="classpath:processpaymentservice.wsdl"
            service="ProcessPaymentServiceService" namespace="http://processpayment.icp.sf/" />
    </http:inbound-endpoint>

    <!-- Transform input of ProcessPayment to input of GetGeoIP -->
    <mulexml:xslt-transformer>
        <mulexml:xslt-text>
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:web="http://www.webservicex.net/">
              <xsl:template match="/">
                <web:GetGeoIP>
                   <web:IPAddress><xsl:value-of select="//paymentType_req" /></web:IPAddress>
                </web:GetGeoIP>
              </xsl:template>
            </xsl:stylesheet>
        </mulexml:xslt-text>
    </mulexml:xslt-transformer>

    <mule:message-properties-transformer>
        <mule:add-message-property key="SOAPAction" value="http://www.webservicex.net/GetGeoIP" />
    </mule:message-properties-transformer>

    <http:outbound-endpoint address="http://www.webservicex.net/geoipservice.asmx"
        exchange-pattern="request-response">
        <cxf:proxy-client soapVersion="1.2" />
    </http:outbound-endpoint>

    <!-- Transform response of GetGeoIP in response of ProcessPayment -->
    <mulexml:xslt-transformer>
        <mulexml:xslt-text>
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:pp="http://processpayment.icp.sf/" xmlns:web="http://www.webservicex.net/">
              <xsl:template match="/">
                <pp:return>
                   <billingID_res>fake billingID_res</billingID_res>
                   <paymentID_res>fake paymentID_res</paymentID_res>
                   <paymentType_res><xsl:value-of select="//web:CountryName"/></paymentType_res>
                </pp:return>
              </xsl:template>
            </xsl:stylesheet>
        </mulexml:xslt-text>
    </mulexml:xslt-transformer>
</mule:flow>
于 2012-04-13T00:39:28.587 回答