2015-10-08 172 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