Michal’s PI tips: Exchange Rates from an XML file on a web page – REST, AXIS
One, quite common requirement on the PI forum has always been a getting an XML file from a web page (in most cases with exchange rates but it can be any other XML file of course). Solution to this issue was in most cases:
– building a java proxy which had to be called inside a ccBPM from a scheduled sender adapter.
– using an external tool (script) – as shown in my other article – PI/XI: how to get an XML file from a web page without own development
Both approaches required either additional development or using some non PI tools – so not very clean. I’ve started wondering if there’s anything else that we could use. It seems that the very old AXIS adapter (available as of XI 3.0) can greatly help in this case.
SOAP sender adapter allows using AXIS extensions and one of the task classes HTTPGetter allows getting an XML file from a URL. In the example below I’m showing how to get the XML file with exchange rates from a web page using a scheduled Axis task.
XML file with exchange rates from http://www.voip.ms/rates/xmlapi.php?dest=United%20States%
What you need to do is to specify:
a) task class,
b) URL (and authentication if exists)
c) interval im miliseconds which will be used to pool the XML file (so once a day for example)
One parameter you need to set for the static URL is the enableREST parameter – you need to set it to true. This will allow proper creation of the PI message from the XML file.
Please have a look at the screenshot below:
And that’s it – there is nothing more you need to do apart from a standard PI flow development.
Sometimes it’s required to call a sync WS to get a message and there is no special request message for that WS. In such a case the same class (or extension to this class) can be used to do the same thing and you don’t need to use external tools or build special java proxies for such purposes.
Please let me know if anyone has already been using this method.