2012-04-11 7 views
1

바로 지금, 청구 시스템을 호출하는 ProcessPayment라는 서비스가 있습니다. 여기서 볼 수 있듯이 지불 서비스에서 다른 결제 서비스로 전화를 걸고 싶습니다. PaymentService의 응답에는 3 개의 데이터 요소가 있습니다. BillingService에는 그 중 하나가 필요합니다.Mule의 CXF 웹 서비스 프록시 구성 문제

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 구성 인바운드 URL을 누를 때 ProcessPayment 서비스 용 wsdl을 생성 할 수 있습니다. 그러나이 URL을 사용하여

<import schemaLocation="".../> 

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

에 대한 수정 된 값을 보여주고, 나는 SOAPui에 서비스를 테스트 할 수 없습니다입니다. 그러나 Mule 수신 주소가 아닌 원래 서비스 주소를 조회하면 실제 서비스를받을 수 있습니다. 그것은 SOAP UI에서도 실행됩니다.

빠른 질문 :

어떻게 흐름을 실행할 수 있습니까? 브라우저 또는 SOAPui에서 인바운드 URL을 호출하기 만하면 올바르게 작동하지 않습니까?

+0

프록시가 작동하는 경우 soapUI (브라우저가 아님)를 사용하여 프록시를 호출 할 수 있어야합니다. –

+0

나는 아직도 당신이하려는 것을 얻지 못한다. 이것은 인바운드 및 아웃 바운드 서비스가 다르기 때문에 분명히 프록시의 유스 케이스처럼 들리지 않습니다. 따라서 Mule에서 ProcessPaymentService를 호스팅하고이 서비스의 결과를 BillingService의 일부 방법으로 보내시겠습니까? 그러나 ProcessPaymentService를 호출 한 사람의 결과는 어떻게됩니까? ProcessPaymentService의 서비스 클래스가 BillingService를 호출해야합니까? –

+0

그래서 인바운드 및 아웃 바운드 끝점이 같은 경우에만 프록시를 사용합니까? 실제로, 나는 하나의 서비스를 가지고 있으며, 그로부터 흐름은 세 가지 서비스로 갈 것입니다. 지금 당장은 하나의 서비스가 다른 서비스를 순차적으로 호출 할 수 없습니다. 그래서이 시나리오를 먼저 시도해 보았습니다. – r3st0r3

답변

2

이제 CXF 프록시를 사용하여 SOAP 봉투 레벨 조작을 수행하는 방법을 보여주는 예제를 만들었습니다. 거기에서 나는 필요한 것을 확장하고 만들 수 있다고 확신합니다.

있다는 점 유의 하시길 바랍니다 :

  • 없음 코드 생성이 필요하지 않습니다, 나는 실제로 그렇지 않으면 작동하지 않습니다 생성 한 클래스를 제거했다. WSDLs + XSD를 사용한이 단일 XML 구성으로 충분합니다.
  • 기본 네임 스페이스에서 생성 된 XSL-T 요소가 Mule 코어 네임 스페이스에서 끝나는 것을 방지하기 위해 Mule 핵심 요소를 정규화했습니다. XSL 조각을 외부화하는 경우에는 필요하지 않습니다.
  • (인위적인) 예는 processpaymentservice.wsdl을 노출합니다. 그것은 paymentType_req의 가치를 취하고 IP 주소 인 척하며 http://www.webservicex.net/geoipservice.asmx에 전화를 걸기 위해 사용합니다. geolocated 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

+0

또 하나. 이 블록의 목적은 정확히 무엇입니까? r3st0r3

+0

1) 모범 사례 가이드를 모른다. 2) SOAPAction 헤더는 webservicex.net에서 필요합니다. 서비스가 아닌 경우 필수 항목이 아닙니다. –

관련 문제