2012-04-11 51 views
1

現在,我有一個名爲ProcessPayment的服務,它調用一個計費系統。正如我們在這裏看到的,我想通過我的付款服務撥打另一個計費服務。 PaymentService的響應有3個數據元素。 BillingService中需要其中之一。Mule的CXF Web服務代理配置問題

如何在Mule中配置兩個或多個服務的流量?我嘗試了各種排列,但它不起作用!

騾-config.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 config入站URL時,我能夠爲ProcessPayment服務生成wsdl。但爲表示使用該網址爲

<import schemaLocation="".../> 

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

修改後的值,我不能夠以測試SOAPUI服務。但是當我打到服務的原始地址,而不是Mule入站地址時,我得到了我的實際服務。它也在SOAP UI中運行。

快速的問題:

如何執行的流程?只需從瀏覽器或SOAPui調用入站網址將無法正常工作?

+0

如果代理正在工作,您應該可以使用soapUI(不是瀏覽器)調用它。 – 2012-04-11 21:55:18

+0

我仍然沒有得到你想要做的。這聽起來不像代理的用例,因爲入站和出站服務是不同的。所以你想要在Mule中託管ProcessPaymentService,並將這個服務的結果發送給BillingService的某種方法?但是,ProcessPaymentService對於調用者的結果是什麼? ProcessPaymentService的服務類不應該是調用BillingService的服務類嗎? – 2012-04-11 22:22:02

+0

所以我們僅在入站和出站端點相同時才使用代理服務器?實際上,我有一項服務,從這一點來看,這個流程將轉到三項服務(稍後)。目前,我無法依次調用其他服務。所以,我想先嚐試一下這個場景。 – r3st0r3 2012-04-12 04:32:25

回答

2

在這裏,我創建了一個演示如何使用CXF代理執行SOAP信封級別操作的示例。從那裏我相信你可以擴大和建立你需要的任何東西。

請注意:需要

  • 沒有生成代碼,其實我不得不刪除您已經生成,否則它是不工作的類。這個帶有WSDLs + XSD的單一XML配置就足夠了。
  • 爲了避免默認命名空間中生成的元素XSL-T在Mule核心命名空間中結束,我已經驗證了Mule核心元素。如果您外部化XSL片段,則不需要此操作。
  • (人爲)示例公開了processpaymentservice.wsdl。它取得了paymentType_req的值,假設它是一個IP地址並用它來呼叫http://www.webservicex.net/geoipservice.asmx。然後使用地理定位的coutry名稱作爲進程支付響應的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> 
+0

我正面臨一個奇怪的問題。它在SOAP UI 4.5中工作正常,但不在SOAP UI 4.0中。想知道原因是什麼。 無論如何,謝謝。現在有道理。我有個問題。是否有設計騾流的最佳實踐指南? – r3st0r3 2012-04-13 04:29:00

+0

另一件事。這個區塊的目的究竟是什麼? r3st0r3 2012-04-13 06:01:13

+0

1)我不知道最佳實踐指南。 2)webservicex.net需要SOAPAction頭文件,但您的服務可能並非如此,所以它不是強制性的。 – 2012-04-13 15:29:55