Anglo
Eider Moore
Overview
Saxon
Saxon is a freely available XSLT/XQuery processor that is written in pure Java. The free version is available from http://saxon.sourceforge.net/. Documentation can be found at http://www.saxonica.com. It is easy to deploy and use since it is pure Java. It also supports calling Java methods from XQuery (browse the documentation to "Using XQuery"/"Extensibility").
Anglo
Anglo is an pre-beta product designed to call Web Services from within Saxon.
Goals
- Call a Web Service from Saxon or any other Java based XQuery engine (like Qexo)
- Not require any external tools or compilation to do so (so no wsdl2java)
- Provide as simple an interface as possible.
- Convert atomic strings into documents (I couldn't find how to do this with a builtin function).
Later goals may include supporting popups for authenticating secure Web Services. Only Saxon is currently supported. In order to support Qexo, it would require some testing and moving some Saxon specfic code to a dynamically loaded class.
Usage
Add declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper"; to your XQuery
Type java -cp saxon8.jar:anglo.jar net.sf.saxon.Query 'query file' at the prompt.
It expects Axis in the same directory as anglo or manually setting the classpath to point to Axis (all 8 jars) using -cp.
Bugs/Issues
- It does not handle converting data types at all... so use a double for a double (not a string)
- Because the main method takes Java Objects for it's method, Saxon passes StringValues? (instead of Strings) and other constructs that Web Services don't recognize. We need to intelligently break these into the proper types for a given call. Anglo currently converts these to Strings. (The code to do this requires Saxon, so would have to be broken out to support other XQuery engines).
- Anglo does not handle changing the end point.
- The interface to call Web Services could be streamlined.
Documentation
Inversion of Control
Some people may feel understandably queasy about using anglo directly as a form of distributed XQuery. To fix this issue we can apply inversion of control (Wikipedia) to break the dependency chain. By replacing:
declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper";
with:
import module namespace anglo = ""http://sig.biostr.washington.edu/dxq/"
at "http://sig.biostr.washington.edu/~ebmoore/dxqFunctions.xq";
Then our XQuery isn't dependent on anglo and we can substitute different Web Service extensions in other XQuery engines just be changing which dxqFunctions file we import.
Source Home
Compiling
Anglo requires Saxon (tested with Saxon 8.5 and 8.7) and a JAX-RPC implementation (I suggest Apache Axis as it is the smallest one I have found) to compile. Use the ant build script.
Required Libraries
Downloads
Example
declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper";
let $a := anglo:xquery("http://cuboid.biostr.washington.edu:8080/SaxonWebService/wsdl/XQuery.wsdl", "XQuery", "doXQuery",
"$root/patient[pnum=117]/pnum")
return $a
One with two calls:
declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper";
let $a := anglo:xquery("http://cuboid.biostr.washington.edu:8080/PublicSaxonWebService/wsdl/XQuery.wsdl", "XQuery", "doXQuery",
"$root/patient[pnum=117]/pnum")
let $b := anglo:xquery("http://cuboid.biostr.washington.edu:8080/PublicSaxonWebService/wsdl/XQuery.wsdl", "XQuery", "doXQuery",
"$root/patient[pnum=117]/surgery/photo[preference=1]")
return
<AllResults>
{$a}
{$b}
</AllResults>
One that returns an array:
declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper";
for $d in anglo:wscall(
"http://femur.biostr.washington.edu:8080/Transformer/wsdl/TransformationWS.wsdl",
"TransformationWS", "transformXYZ", "P174", "MNI", 0.0, 1.0, 2.0)
return <d>{$d}</d>
Converting a String into a document:
declare namespace anglo="java:edu.washington.biostr.sig.anglo.WebServiceWrapper";
let $q := '<q>
<TransformServerParam coord="Site" source="0" target=""/>
<SiteSet>
<Site z0="-3.41681" y0="5.82331" space0="P176" x0="-55.183" space="MNI"/>
<Site z0="16.3706" y0="-14.5631" space0="P176" x0="-56.8303" space="MNI"/>
</SiteSet>
</q>'
for $site in anglo:toDocument($q)//Site
return
$site
