首页 > 解决方案 > Mule 4 - 使用 Anypoint studio 7 创建 WSDL Web 服务

问题描述

我已经阅读了有关使用最新 mule (https://docs.mulesoft.com/apikit/4.x/apikit-4-soap-prerequisites-task)创建肥皂网络服务的新方法的文档,但它没有真的有帮助。

因为我尝试执行以下操作,以该教程为例,当用户输入名称、大小、电子邮件并在OrderTshirt函数中发送请求时,我的流程将调用 java 类中的方法,可能int OrderTShirt.order(String input)在其中输入 concat 所有名称、大小, 和 email 信息,并返回 orderId,并提交回响应给用户。我该如何处理?

这是我现在拥有的代码,但我不知道如何很好地使用该数据波组件,有人可以给我一个例子吗?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit-soap="http://www.mulesoft.org/schema/mule/apikit-soap" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/apikit-soap http://www.mulesoft.org/schema/mule/apikit-soap/current/mule-apikit-soap.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <http:listener-config name="api-httpListenerConfig">
        <http:listener-connection host="0.0.0.0" port="9999"/>
    </http:listener-config>
    <apikit-soap:config name="soapkit-config" port="TshirtServicePort" service="TshirtService" wsdlLocation="Tshirt2.wsdl"/>
    <flow name="api-main">
        <http:listener config-ref="api-httpListenerConfig" path="/TshirtService/TshirtServicePort">
            <http:response>
                <http:body>#[payload]</http:body>
                <http:headers>#[attributes.protocolHeaders default {}]</http:headers>
            </http:response>
            <http:error-response>
                <http:body>#[payload]</http:body>
                <http:headers>#[attributes.protocolHeaders default {}]</http:headers>
            </http:error-response>
        </http:listener>
        <apikit-soap:router config-ref="soapkit-config">
            <apikit-soap:message>#[payload]</apikit-soap:message>
            <apikit-soap:attributes>#[
              %dw 2.0
              output application/java
              ---
              {
                  headers: attributes.headers,
                  method: attributes.method,
                  queryString: attributes.queryString
            }]</apikit-soap:attributes>
        </apikit-soap:router>
    </flow>
    <flow name="OrderTshirt:\soapkit-config" doc:id="969489c2-709c-43b7-915c-cc92d9f3c8c9">
        <ee:transform doc:name="Transform Message" doc:id="5771f4b9-0060-4658-aa8a-fee10efc02c5" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/java
ns ns0 http://schemas.xmlsoap.org/soap/envelope
---
{
    body:{
        ns0#orderTshirtResponse:{
            orderId:"10"
        }
    } write "application/xml"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
    </flow>
    <flow name="ListInventory:\soapkit-config">
        <ee:transform doc:id="431ad9c7-f0bf-4b32-88bc-bbe8c6815317">
            <ee:message>
                <ee:set-payload><![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
    body: {
        soap#Fault: {
            faultcode: "soap:Server",
            faultstring: "Operation [ListInventory:\soapkit-config] not implemented"
        }
    } write "application/xml"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
    </flow>
    <flow name="TrackOrder:\soapkit-config">
        <ee:transform doc:id="a09a0cc3-f28a-49aa-bb32-77368340a522">
            <ee:message>
                <ee:set-payload><![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
    body: {
        soap#Fault: {
            faultcode: "soap:Server",
            faultstring: "Operation [TrackOrder:\soapkit-config] not implemented"
        }
    } write "application/xml"
}]]></ee:set-payload>
            </ee:message>
        </ee:transform>
    </flow>
</mule>

标签: mulemule-esb

解决方案


推荐阅读