如何创建一个Mule Project v3.8,它将消息重定向到外部Web服务?

时间:2016-11-15 01:49:10

标签: wsdl mule

我想创建一个Mule项目,其想法是将SOAP消息(例如通过soapUI)发送到此项目,然后将消息重定向到外部Web服务。 我已经阅读了文档,但我无法弄清楚如何完成这个简单的任务。

如果有人能帮助我,我将不胜感激。我正在使用Mule v3.8。

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以按照hereMuleSoft Documentation

中的说明使用Web Service Consumer连接器

答案 1 :(得分:-1)

一般来说,
你可以使用:
HTTP端点(请求 - 响应) - >
CXF组件(适用于您的代理服务,可选) - >
Web服务消费者(调用所需服务)

如果我不是很清楚,我可以帮助你建立这个项目。

<强>更新
我提供了一个简单的服务,现在我们有了wsdl:

<wsdl:definitions name="SimpleServiceService" targetNamespace="http://simple/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://simple/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xs:schema elementFormDefault="unqualified" targetNamespace="http://simple/" version="1.0" xmlns:tns="http://simple/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="doSomething" type="tns:doSomething"/>
            <xs:element name="doSomethingResponse" type="tns:doSomethingResponse"/>
            <xs:complexType name="doSomething">
                <xs:sequence>
                    <xs:element minOccurs="0" name="Input" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="doSomethingResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="return" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="doSomethingResponse">
        <wsdl:part element="tns:doSomethingResponse" name="parameters"/>
    </wsdl:message>
    <wsdl:message name="doSomething">
        <wsdl:part element="tns:doSomething" name="parameters"/>
    </wsdl:message>
    <wsdl:portType name="SimpleService">
        <wsdl:operation name="doSomething">
            <wsdl:input message="tns:doSomething" name="doSomething"/>
            <wsdl:output message="tns:doSomethingResponse" name="doSomethingResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SimpleServiceServiceSoapBinding" type="tns:SimpleService">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="doSomething">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="doSomething">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="doSomethingResponse">
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SimpleServiceService">
        <wsdl:port binding="tns:SimpleServiceServiceSoapBinding" name="SimpleServicePort">
            <soap:address location="http://exoldy-simple-mule-project.cloudhub.io/service"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

接下来,我们需要使用在Mule

上实现的代理服务与此服务进行交互
<mule xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd">

    <ws:consumer-config name="Web_Service_Consumer" service="SimpleServiceService" port="SimpleServicePort" serviceAddress="http://exoldy-simple-mule-project.cloudhub.io/service" wsdlLocation="http://exoldy-simple-mule-project.cloudhub.io/service?wsdl" doc:name="Web Service Consumer"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>

    <flow name="external" initialState="started">
        <http:listener config-ref="HTTP_Listener_Configuration1" path="service" doc:name="Receive HTTP request" doc:description="This endpoint receives an HTTP message."/>
        <logger message="#[flow.name]" level="INFO" doc:name="Logger"/>
        <cxf:proxy-service payload="body" doc:name="CXF" namespace="http://simple/" service="SimpleServiceService" wsdlLocation="http://exoldy-simple-mule-project.cloudhub.io/service?wsdl"/>
        <ws:consumer config-ref="Web_Service_Consumer" operation="doSomething" doc:name="Web Service Consumer"/>
    </flow>
</mule>

现在一切都应该起作用,至少它适用于我)