<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<mulexml:namespace-manager includeConfigNamespaces="true">
<mulexml:namespace prefix="ns0" uri="http://www.cpscreen.com/schemas"/>
</mulexml:namespace-manager>
<configuration doc:name="Configuration">
<expression-language autoResolveVariables="true">
<import class="org.mule.util.StringUtils" />
<import class="org.mule.util.ArrayUtils" />
</expression-language>
</configuration>
<flow name="user_provisions_-_xml_postFlow1" doc:name="user_provisions_-_xml_postFlow1">
<file:inbound-endpoint path="E:/temp/mule" responseTimeout="10000" doc:name="File">
<file:filename-regex-filter pattern="in_(.*).csv" caseSensitive="true"/>
</file:inbound-endpoint>
<file:file-to-string-transformer doc:name="File to String"/>
<expression-component doc:name="Expression"><![CDATA[java.util.List items = new java.util.ArrayList(Arrays.asList(payload.split("\n")));
items.remove(0);;
java.lang.String listString = '';
for (String s : items) {
listString += s + "\n";
}
payload=listString.trim();]]></expression-component>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="46908" path="userprovision" method="POST" doc:name="HTTP"/>
<object-to-string-transformer mimeType="text/xml" doc:name="Object to String"/>
<splitter expression="#[xpath('//UpdateUserRequest')]" doc:name="Splitter"/>
<logger message="Here is #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
我越來越喜歡,如何拆分Mule Anypoint中的XML?
WARN 2014-09-10 15:30:27,181 [[user_provisions_-_xml_post].user_provisions_-_xml_postFlow1.stage1.02] org.mule.routing.ExpressionSplitter: Splitter returned no results. If this is not expected, please check your split expression
更新:
我得到了其中的問題是,但我可以解決分裂問題。由於namespace
在XML分路器不評估分割表達...
<?xml version="1.0" encoding="UTF-8"?>
<UpdateUserRequests xmlns="http://www.cpscreen.com/schemas">
<UpdateUserRequest userId="Test" account="Test" password="Test">
<User>
<Account id="4">34567</Account>
<UserId>Test</UserId>
<Profile>Admin</Profile>
<PersonName>
<GivenName>Sahak</GivenName>
<FamilyName>Kn</FamilyName>
</PersonName>
</User>
</UpdateUserRequest>
<UpdateUserRequest userId="Test" account="Test" password="Test">
<User>
<Account id="5">12345</Account>
<UserId>Test</UserId>
<Profile>Admin</Profile>
<PersonName>
<GivenName>Arun</GivenName>
<FamilyName>Kumar</FamilyName>
</PersonName>
</User>
</UpdateUserRequest>
</UpdateUserRequests>
的如果我刪除xmlns="http://www.cpscreen.com/schemas"
這是拆分到多個
如何添加吐表達式,如果有一個命名空間中xml?
我不能這樣做,因爲我正在向其他ESB發送CSV數據(因爲Mule數據映射器已付款),並且它返回了我的xml。我需要拆分XML並閱讀 – Sahal 2014-09-10 11:30:57
我得到了我所面臨的問題..更新了項目。名稱空間在xml中存在,這是它沒有拆分的原因 – Sahal 2014-09-10 11:31:41