2012-04-11 116 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