Reading an XML file into WSO2 ESB; Transform it and expose it as an API

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 "home/nuwanbando/temp/files/out" location.

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;

 

Advertisements

5 thoughts on “Reading an XML file into WSO2 ESB; Transform it and expose it as an API”

  1. Thanks, very nice. However it will be more ‘complete’ for novices like me to have either additional steps on starting points and deployment or point to those links.

    Like

      1. Thanks for the links, I am already familiar with those. My bad if I wasn’t clear in previous comment. I thought if you also specified which folders to place those xml and compiled classes then one would have a complete example of developing and deploying. I guess your audience was not novice like me. I like the example and style of this blog http://bushorn.com/simple-jms-use-case-on-wso2-esb/

        Like

  2. Thanks for the links, I am already familiar with those. My bad if I wasn’t clear in previous comment. I thought if you also specified which folders to place those xml and compiled classes then one would have a complete example of developing and deploying. I guess your audience was not novice like me. I like the example and style of this blog http://bushorn.com/simple-jms-use-case-on-wso2-esb/

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s