Reputation: 440
I am trying to find a way to load a custom xml file to a mule flow and may-be get it as a variable. For eg;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<LastName>Smith</LastName>
<Sales>16753</Sales>
<Country>UK</Country>
<Quarter>Qtr 3</Quarter>
</record>
<record>
<LastName>Johnson</LastName>
<Sales>14808</Sales>
<Country>USA</Country>
<Quarter>Qtr 4</Quarter>
</record>
</data-set>
Please help.
Upvotes: 1
Views: 2018
Reputation: 440
I followed the answer by @Ryan Hoegg and after a few modifications my answer is as below:
Global Element:
<spring:beans>
<spring:bean id="LoadFile" name="Bean" class="java.lang.String">
<spring:constructor-arg>
<spring:bean id="Test" name="org.springframework.util.FileCopyUtils" class="org.springframework.util.FileCopyUtils" factory-method="copyToByteArray">
<spring:constructor-arg type="java.io.InputStream" value="classpath:MSG_IDENTIFIER.xml"/>
</spring:bean>
</spring:constructor-arg>
</spring:bean>
</spring:beans>
To Retrieve:
<set-variable variableName="Contents" value="#[app.registry['LoadFile']]" doc:name="Variable"/>
P.S - I placed the file under src/main/resources
Upvotes: 2
Reputation: 2475
One way to get the contents of a file into a flow variable is to create a spring bean with the contents of the file as described in this Stack Overflow question. Then, you can refer to it using MEL:
<set-variable variableName="niftyData" value="#[app.registry['myBeanName']]" />
Upvotes: 1
Reputation: 8311
You could import the custom configuration file in following way :-
<spring:beans>
<spring:import resource="domain-A-config.xml" />
<spring:import resource="domain-B-config.xml" />
<spring:import resource="admin-config.xml" />
</spring:beans>
Please find the reference below :- http://www.mulesoft.org/documentation/display/current/Modularizing+Your+Configuration+Files+for+Team+Development
Upvotes: 1