Thursday, September 5, 2013

Datapower: Extract an URL from XML, fetching content and binary transformation

I would like to share a simple configuration I have done in order to extract an URL from given XML, fetching it and encoding the content while returning it in soap response. It might be valuable for those who are looking for selecting xml elements in xsl regardless their namespace and how to transform binary content.

First we should extract ip, port, path and query arguments and construct a full URL. No need to say that this is the worst representation for an URL; but this is what asked from us.

A sample xml is: The URL extractor XSD is (AtmesUrlExtractor.xsl in policy flow):

After extracting the URL and assigning the result to a variable atmes_fetch_url; we use fetcher component to fetch the content (in this point we reference to variable with var://context/atmes_fetch_url):

This fetcher puts content is into "PIPE". Then our binary transformer is activated:

The important thing above is call to pkcs7-convert-input.ffd. It puts all the content in a xml structure so that we can proceed with xslt although it is not an xml actually. It is very easy to understand how it works; it is a standard file in datapower. It puts all the content under object/message tag. The import thing is that you must choose it as a binary in component details screen as seen below (even if it is not a binary; a text; anything which is not xml.)

1 comment: