2017-01-31 28 views
0

特定元素的所有子節點我有一個SOAP請求信封看起來是這樣的:Mule-解析SOAP封套

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tsh="http://mulesoft.org/tshirt-service"> 
    <soapenv:Header> 
     <tsh:AuthenticationHeader> 
     <apiKey>?</apiKey> 
     </tsh:AuthenticationHeader> 
    </soapenv:Header> 
    <soapenv:Body> 
     <tsh:OrderTshirt> 
     <size>xxl</size> 
     <email>[email protected]</email> 
     <name>xyz</name> 
     <address1>aaaa</address1> 
     <address2>asdf</address2> 
     <city>werty</city> 
     <stateOrProvince>sdd</stateOrProvince> 
     <postalCode>111111</postalCode> 
     <country>India</country> 
     </tsh:OrderTshirt> 
    </soapenv:Body> 
</soapenv:Envelope> 

現在在這裏,我需要解析的<tsh:OrderTshirt>即所有子元素解析後的輸出應該是這樣的:

<tsh:OrderTshirt> 
     <size>xxl</size> 
     <email>[email protected]</email> 
     <name>xyz</name> 
     <address1>aaaa</address1> 
     <address2>asdf</address2> 
     <city>werty</city> 
     <stateOrProvince>sdd</stateOrProvince> 
     <postalCode>111111</postalCode> 
     <country>India</country> 
     </tsh:OrderTshirt> 

我已經通過在騾子的命名空間管理聲明命名空間解析一個元素的想法。 (簡稱reading soap header element in payload)。

不確定如何使用它的子元素解析節點。

請分享您的想法:)

回答

0

取決於你想要達到的目標。 身體需要發送到SOAP Web服務?

或者你想提取的值?

使用DataWeave很容易,代碼中不需要額外的名稱空間聲明。

XML將成爲您的有效載荷,你可以參照體:

%dw 1.0 
%output application/xml 
--- 
payload.Envelope.Body 

但是它會輸出在頂部還有一個XML頭。

看看這裏如何刪除它:

https://forums.mulesoft.com/questions/51394/remove-xml-definition-from-dataweave-output.html

否則使用空間聲明和使用集有效載荷和值使用指XML主體的XPath表達式,從而成爲有效載荷。