I have just finished a little extension function for Saxon, to be able to send HTTP request from XSLT 2.0 (and get the result back). The idea is based on the SOAP extension from Andrew Welch, but is less restricted, as it can perform other HTTP requests (besides SOAP request over HTTP.)
The function take two parameters: a URI and an element that describe the request (the payload, the headers, the HTTP method, etc.) The later looks like:
<http-request method="post" mime-type="text/xml" charset="utf-8"> <header name="Header-Name">...</header> <header name="Header2-Name">...</header> <body> The textual value of body will be the payload of the HTTP request... </body> </http-request>
Let's say such an element is bound to the variable $request
, then you can call
ex:http-send($request, 'http://...')
, and you will get a result that will look like:
<http-response code="200"> <message>OK</message> <header name="Header-Name">...</header> <header name="Header-x-Name">...</header> <body> The textual value of body was the payload of the HTTP response... </body> </http-response>
All the info, javadoc, JAR file, sample, can be found at http://fgeorges.org/xslt/saxon-ext/. This page contains a full sample sending a SOAP message to a Web service and formating the result to a simple text.
Posted by Florent Georges, on 2008-03-31T05:16:00, tags: expath, http, saxon and xslt.