2014-09-02 43 views
0

我正面临一个问题。从骡子读取单行并转换为骡子中的SOAP请求

要求是我有一个csv文件,并应该转换为soap请求(soap消费者组件)。问题是所有的csv行都是一次性转换的。在我的情况下,soap请求无法处理一个请求中的所有行。它应该是多个呼叫。

我做了什么,要完成这一

<?xml version="1.0" encoding="UTF-8"?> 

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
http://www.mulesoft.org/schema/mule/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd 
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd 
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd 
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd"> 
    <ws:consumer-config name="Web_Service_Consumer1" wsdlLocation="CPAdministration_updated.wsdl" service="AdminService" port="AdminEndpoint" serviceAddress="http://localhost/FM/service/Hrportal?wsdlformule" doc:name="Web Service Consumer"/> 
    <data-mapper:config name="CSV_To_Xml_UpdateUserRequest_" transformationGraphPath="csv_to_xml_updateuserrequest__2.grf" doc:name="CSV_To_Xml_UpdateUserRequest_"/> 
    <flow name="soapFlow1" doc:name="soapFlow1"> 
     <file:inbound-endpoint path="E:/temp/mule" responseTimeout="10000" doc:name="File"/> 
     <data-mapper:transform config-ref="CSV_To_Xml_UpdateUserRequest_" doc:name="CSV To Xml&lt;UpdateUserRequest&gt;" /> 
     <logger message="Converted xml is here #[payload]" level="INFO" doc:name="Logger"/> 
     <ws:consumer config-ref="Web_Service_Consumer1" operation="UpdateUser" doc:name="Web Service Consumer"/> 
    </flow> 
</mule> 

回答

0

一种方法是使用分离器和聚合器。你的流可能看起来像这样:

<flow name="soapFlow1" doc:name="soapFlow1"> 
    <file:inbound-endpoint path="E:/temp/mule" responseTimeout="10000" doc:name="File"/> 
    <data-mapper:transform config-ref="CSV_To_Xml_UpdateUserRequest_" doc:name="CSV To Xml&lt;UpdateUserRequest&gt;" /> 
    <logger message="Converted xml is here #[payload]" level="INFO" doc:name="Logger"/> 
    <splitter expression="#[xpath('//item')]" doc:name="Splitter" enableCorrelation="ALLWAYS"/> 
    <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/> 
    <ws:consumer config-ref="Web_Service_Consumer1" operation="UpdateUser" doc:name="Web Service Consumer"/> 
    <message-chunk-aggregator failOnTimeout="true" doc:name="Message Chunk Aggregator"/> 
</flow> 

xpath表达式显然必须改变,以适应你的情况。