Recently was working on a project where I had a to read an XML file from an FTP location, transform it and expose it as an API. Used WSO2 ESB 4.6.0 for this usecase; and I thought of documenting it for later reference. So here it goes
First the proxy that read the file from FTP and dump it to a defined location, (VFSProxy.xml)
This proxy will dump the file to
This file need to be read on-demand, once requested. ESB by default does not have a mediator to read XML files so that the mediation flow can manipulate the content, hence we have to write a custom class mediator to do this job. The code is as follows,
The code will read the file and add it to the synapse message context as an OMElement.
Now we will write a sequence which uses this class mediator; read the file and transform it through an XSLT
Next attach this sequence to an API, and expose it as a REST endpoint
That’s pretty much it.
important: This sample is tested on ESB 4.6.0 only;