Access and parse the resource catalogue

Revision for “Access and parse the resource catalogue” created on February 12, 2015 @ 16:33:40

Title
Access and parse the resource catalogue
Content
<h2>First a short overview of the resource catalogue</h2> Main page or root of the resource catalogue ex. <code>http://hydra.cnet.se:44441/</code> <a href="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_root.png"><img class="alignnone size-medium wp-image-494" src="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_root-283x300.png" alt="RC_root" width="283" height="300" /></a> List of actions <code>http://hydra.cnet.se:44441/services/catalogue/actions </code> <a href="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_listActions.png"><img class="alignnone size-medium wp-image-496" src="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_listActions-270x300.png" alt="RC_listActions" width="270" height="300" /></a> List of access resources <code>http://hydra.cnet.se:44441/IoTresources</code> <a href="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_resources.png"><img class="alignnone size-medium wp-image-499" src="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_resources-300x213.png" alt="RC_resources" width="300" height="213" /></a> List of State variables <code>http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables</code> <a href="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_services.png"><img class="alignnone size-medium wp-image-500" src="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_services-300x143.png" alt="RC_services" width="300" height="143" /></a> Select a state variable and get latest 180 measurements <code>http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables/currentconsumption?take=180</code> <a href="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_measurements.png"><img class="alignnone size-medium wp-image-501" src="http://www.iotworldservices.com/wp-content/uploads/2015/01/RC_measurements-300x163.png" alt="RC_measurements" width="300" height="163" /></a> <h2>Read xml with Javascript</h2> <code> function readXml(url) { var xhr = createCORSRequest('GET', url); if (!xhr) { console.log('CORS not supported'); return; }</code> // Response handlers. xhr.onload = function () { var xml = xhr.responseText; if (typeof firstAction !== 'undefined') { console.log(xml); } }; xhr.onerror = function () { console.log('Woops, there was an error making the request.'); }; xhr.send(); } function createCORSRequest(method, url) { var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr) { // XHR for Chrome/Firefox/Opera/Safari. xhr.open(method, url, true); } else if (typeof XDomainRequest != "undefined") { // XDomainRequest for IE. xhr = new XDomainRequest(); xhr.open(method, url); } else { // CORS not supported. xhr = null; } return xhr; } &nbsp; Ex. <code>readXml('http://hydra.cnet.se:44441/services/catalogue/actions')</code>
Excerpt


OldNewDate CreatedAuthorActions
February 12, 2015 @ 16:33:40 Peter Rosengren
January 19, 2015 @ 15:46:09 Vivian Esquivias
January 19, 2015 @ 15:44:17 Vivian Esquivias
January 19, 2015 @ 15:43:06 Vivian Esquivias
January 19, 2015 @ 15:39:33 Vivian Esquivias
January 19, 2015 @ 15:31:28 Vivian Esquivias
January 19, 2015 @ 15:29:18 Vivian Esquivias
January 19, 2015 @ 15:26:35 Vivian Esquivias
January 19, 2015 @ 15:24:03 Vivian Esquivias
January 19, 2015 @ 15:22:46 Vivian Esquivias