Mule利用Groovy脚本生成XML(二)
接上文所述:
<flow name="depttodeptFlow3">
<http:listener config-ref="HTTP_Listener_Configuration" path="/X" doc:name="HTTP"/>
<db:select config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[select Dept_Name deptName,dept_code from dept_dict]]></db:parameterized-query>
</db:select>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy"><![CDATA[def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
xml.order(xmlns: 'urn:acme:order:3:1') {
payload.each { p ->
'ns1:Product' {
'ns1:Code'(p.Dept_Code)
'ns1:Quantity'(p.DeptName)
}
}
}
result = writer.toString()]]></scripting:script>
</scripting:component>
</flow>
运行结果:
|