2015-10-08 173 views
0

我有一個.NET web服務,它有一個接受字符串的方法。在Mulesoft的Anypoint工作室中,我成功構建了一個接受POST的流,將POSTed字符串傳遞到服務中,並返回一個操作結果。MuleSoft DataWeave - 通過Web服務使用者調用.NET SOAP服務

我現在正在嘗試爲類似服務創建一個流,但該服務接受自定義對象而不是字符串。當我使用SOAP UI直接測試我的服務時,我傳入以下XML併成功在我的服務中構建對象,並且MyFirstString和MySecondString值可用於該服務。

SOAP UI XML:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pra="http://schemas.datacontract.org/2004/07/Pra.Lib.Transformation"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tem:Transform>   
     <tem:transformationData>    
      <pra:MyFirstString>test1</pra:MyFirstString> 
      <pra:MySecondString>test2</pra:MySecondString> 
     </tem:transformationData> 
     </tem:Transform> 
    </soapenv:Body> 
</soapenv:Envelope> 

然而,當我用我的騾子流動和放棄我DataWeave在我的Web服務消費者的面前,它自動建立不與服務工作的XML字符串。當我將調試器附加到服務時,它顯示對象未被成功構建/映射...在Web Service使用者調用完成後,MyFirstString和MySecondString爲空。

DataWeave代碼:

%dw 1.0 
%output application/xml 
%namespace ns0 http://tempuri.org/ 
--- 
//Some output fields where skipped as the structure is too deep (more than 2 levels). 
//To add missing fields click on the scaffold icon (second on the toolbar). 
{ 
    ns0#Transform: { 
     ns0#transformationData: { 
      Xml: "test1", 
      Xslt: "test2" 
     } 
    } 
} 

DataWeave輸出:

<?xml version='1.0' encoding='windows-1252'?> 
<ns0:Transform xmlns:ns0="http://tempuri.org/"> 
    <ns0:transformationData> 
    <Xml>test1</Xml> 
    <Xslt>test2</Xslt> 
    </ns0:transformationData> 
</ns0:Transform> 

返回的錯誤消息是「在操作 '變換' 反序列化請求消息的主體錯誤OperationFormatter遇到無效的消息正文。希望找到名稱爲'Transform'且名稱空間爲'http://tempuri.org/'的節點類型'Element'。找到節點類型爲'Element'的名稱爲'EXTRACT_DETAIL'和名稱空間''的消息淨荷類型爲:ElementNSImpl「

所以,如果我明白這個錯誤......我的問題是我如何編寫DataWeave以SOAP UI使用的SOAP信封格式輸出......因爲DataWeave生成的元素結構似乎是給我的問題?非常感謝。

回答

0

一位開發人員能夠指引我走向正確的方向。在AnyPoint Studio中,在DataWeave/TransformMessage組件的屬性選項卡上,我必須單擊該按鈕才能使用腳手架輸出結構。這生成了以下輸出(下面以粗體顯示的語法更改)。我原本以爲所有腳手架在第一次將組件放入流中時都是自動的。

語法改變:

   ns1#Xml: "test1", 
       ns1#Xslt: "test2" 

整個腳手架:

%dw 1.0 
%output application/xml 
%namespace ns0 http://tempuri.org/ 
--- 
//Some output fields where skipped as the structure is too deep (more than 2 levels). 
//To add missing fields click on the scaffold icon (second on the toolbar). 
{ 
    ns0#Transform: { 
     ns0#transformationData: { 
      ns1#Xml: "test1", 
      ns1#Xslt: "test2" 
     } 
    } 
} 

點擊這裏查看腳手架按鈕 screen capture

0

是配置您的WSDL後,您可以拖放數據編織,然後點擊腳手架,它會爲你生成合適的結構。

enter image description here