0
我有一個簡單的代理服務,它需要將XML有效負載轉換爲CSV消息。爲此我使用了smooks mediator。以下是我的代理服務。WSO2 ESB Smooks - XML到CSV轉換
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TestProxy" startOnLoad="true" trace="disable"
transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="custom">
<property name="STATUS" value="TESTING PROXY SERVICE"/>
</log>
<payloadFactory media-type="xml">
<format>
<csv-set>
<csv-record number="2">
<Name>Jhone</Name>
<City>Colombo</City>
<Age>32</Age>
</csv-record>
<csv-record number="3">
<Name>Doe</Name>
<City>Jaffna</City>
<Age>32</Age>
</csv-record>
</csv-set>
</format>
<args/>
</payloadFactory>
<log level="full"/>
<smooks config-key="gov:Test/smooks/TestSmooksConfig.xml">
<input type="xml"/>
<output type="text"/>
</smooks>
<log level="custom">
<property name="STATUS" value="PROCESSED MSG******"/>
</log>
<log level="full"/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
以下是我的Smooks配置。
<?xml version="1.0" encoding="UTF-8"?><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:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="inputType">input.xml</param>
<param name="stream.filter.type">SAX</param>
<param name="input.xml" type="input.type.actived">File:/F:\Practicals\WSO2\vfs_file_listening\input-csv\b.xml</param>
</params>
<ftl:freemarker applyOnElement="#document">
<ftl:template><![CDATA["Name","City","Age"
<#list .vars["csv-set"]["csv-record"] as csv_record>
"${.vars["csv_record"]["Name"]}","${.vars["csv_record"]["City"]}","${.vars["csv_record"]["Age"]}"
</#list>]]></ftl:template>
<param name="includeFieldNames">true</param>
<param name="seperator">,</param>
<param name="quote">"</param>
<param name="csvFields">Name,City,Age</param>
<param name="messageType">CSV</param>
<param name="templateDataProvider">input</param>
</ftl:freemarker>
<resource-config selector="#document">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
</smooks-resource-list>
輸出消息僅打印以下內容。
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ax:text xmlns:ax="http://ws.apache.org/commons/ns/payload">"Name","City","Age"</ax:text>
</soapenv:Body>
</soapenv:Envelope>
不與輸入XML標籤中的數據,任何人都可以指出我做錯了什麼?
在此先感謝。