这是可能的,但不是你使用的方式......例如,这是我将很快发布的博客文章的配置:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="orderIncommingTransformer">
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd" xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.2.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="stream.filter.type">SAX</param>
<param name="inputType">input.csv</param>
<param name="input.csv" type="input.type.actived">Workspace://MyRegistryResources/models/incomming_csv.csv</param>
<param name="default.serialization.on">false</param>
</params>
<csv:reader fields="orderid,customerid,date,price" recordElementName="AddOrder" rootElementName="AddOrder_batch_req" separator=","/>
<ftl:freemarker applyOnElement="#document">
<ftl:template><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<#list .vars["AddOrder_batch_req"] as AddOrder_batch_req>
<ns1:AddOrder_batch_req xmlns:ns1="http://wso2.org/sample/shop/order">
<#list .vars["AddOrder_batch_req"]["AddOrder"] as AddOrder>
<ns1:AddOrder>
<ns1:orderID>${.vars["AddOrder"]["orderid"]}</ns1:orderID>
<ns1:customerID>${.vars["AddOrder"]["customerid"]}</ns1:customerID>
<ns1:date>${.vars["AddOrder"]["date"]}</ns1:date>
<ns1:price>${.vars["AddOrder"]["price"]}</ns1:price>
</ns1:AddOrder>
</#list>
</ns1:AddOrder_batch_req>
</#list>
</soapenv:Body>
</soapenv:Envelope>]]></ftl:template>
<param name="modelSrc">Workspace://MyRegistryResources/models/outgoing_xml_from_csv.xml</param>
<param name="modelSrcType">XML</param>
<param name="messageType">XML</param>
<param name="templateDataProvider">input</param>
</ftl:freemarker>
<resource-config selector="#document">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
</smooks-resource-list>
</localEntry>
输出是:
<soapenv:Body>
<ns1:AddOrder_batch_req xmlns:ns1="http://wso2.org/sample/shop/order">
<ns1:AddOrder>
<ns1:orderID>1</ns1:orderID>
<ns1:customerID>1</ns1:customerID>
<ns1:date>2011-12-26T18:28:48.214+05:30</ns1:date>
<ns1:price>456.76</ns1:price>
</ns1:AddOrder>
<ns1:AddOrder>
<ns1:orderID>2</ns1:orderID>
<ns1:customerID>3</ns1:customerID>
<ns1:date>2011-12-27T18:28:48.214+05:30</ns1:date>
<ns1:price>451.76</ns1:price>
</ns1:AddOrder>
<ns1:AddOrder>
<ns1:orderID>3</ns1:orderID>
<ns1:customerID>3</ns1:customerID>
<ns1:date>2011-12-27T18:28:48.214+05:30</ns1:date>
<ns1:price>451.76</ns1:price>
</ns1:AddOrder>
</ns1:AddOrder_batch_req>
</soapenv:Body>
使用命名空间。我将 DVS 3.7.1 用于此 smooks 配置并复制/粘贴到 WSO2 ESB 4.8.1 内的本地条目,它就像一个魅力。
问候。