|
|
|||
6.1 Using XRPC from JavaScriptWARNING: XRPC still makes use of the old compiler backend and does not use the optimizing algebraic query compiler. Therefore, its query performance can sometimes be inferior to other queries handled by MonetDB/XQuery. Also, as the old compiler backend is gradually phased out, it gets to be less well-maintained and tested in general. Use with caution. We hope to port XRPC to the algebra backend soon. XRPC allows to make SOAP calls to a MonetDB/XQuery server. With XRPC you can invoke predefined XQuery Functions. The XQuery function must be defined in an XQuery Module file that should be accessible by the server via an URL. Because XRPC makes use of such predefined modules, MonetDB/XQuery can pre-process the module and perform query optimization beforehand. This makes XRPC a highly efficient API, allowing in simple queries for response times of for less than 10 milliseconds. By default when MonetDB/XQuery starts, its HTTP server is started on port 50001.
It serves out the directory is in WARNING: XRPC still makes use of the old compiler backend and does not use the optimizing algebraic query compiler. Therefore, its query performance can sometimes be inferior to other queries handled by MonetDB/XQuery. Also, as the old compiler backend is gradually phased out, it gets to be less well-maintained and tested in general. Use with caution. We hope to port XRPC to the algebra backend soon. 6.1.1 APIIn the file For safety reasons, Internet Explorer and FireFox usually only allow SOAP requests to be sent from Javascript to the same host as the web-server!!. This restriction also affects this JavaScript XRPC API. The main function is function XRPC(posturl, /* Your XRPC server. Usually: "http://yourhost:yourport/xrpc" */
module, /* (logical) module namespace URI (NB: do not use the user defined prefix of the module!). Must match XQuery module definition! */
moduleurl, /* module (physical) at-hint URL. Module file must be here! */
method, /* method name (matches function name in module) */
arity, /* arity of the method, i.e. number of parameters. */
call, /* one or more XRPC_CALL() parameter specs (concatenated strings) */
callback); /* a JavaScript callback function that should be called when the response message is received*/
What you get back is the full SOAP result message described in TODO. You can process it in Javascript as you like. The function parameters is a string that can be constructed using the following helper functions: function XRPC_CALL(parameters); function XRPC_SEQ(sequence); function XRPC_ATOM(type, value); function XRPC_ELEMENT(value); Each set of parameters is enclosed in an XRPC_CALL. It is in fact possible to pass multiple such XRPC_CALLS. This means the function will be invoked multiple times and you will get back multiple result sequences (one for each call). For each parameter in a function call, you specify a sequences, i.e. an XRPC_SEQ. Inside a sequence,
you find zero or more XRPC_ATOMs and/or XRPC_ELEMENTs. For atomic types, the type is assumed
to be from the 6.1.2 ExampleYou must include the file <html>
<head>
<script type="text/javascript" src="xrpcwebclient.js">
var clnt = new XRPCWebClient();
</script>
</head>
..
Then you fire off from Javascript an XRPC call, e.g. calling the XRPC('http://localhost:50001',
'xrpc-test-function',
'http://www.monetdb.nl/XQuery/files/xrpc-mod.xq",
'add',
'2',
XRPC_CALL(XRPC_SEQ(XRPC_ATOM('integer', '100') + XRPC_ATOM('integer', '200'))),
exampleCallback);
exampleCallback(result) {
alert(result);
}
The MonetDB/XQuery administrative GUI ( |
||||
|
|
||||
| © 1994-2010 CWI | Contact us Legal HG web Bugs TestWeb PermaStore | |||