First a short overview of the resource catalogue
Main page or root of the resource catalogue ex. http://hydra.cnet.se:44441/
List of actions http://hydra.cnet.se:44441/services/catalogue/actions
List of access resources http://hydra.cnet.se:44441/IoTresources
List of State variables http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables
Select a state variable and get latest 180 measurements http://hydra.cnet.se:44441/IoTresources/3/services/IoTObservation/statevariables/currentconsumption?take=180
Read xml with Javascript
function readXml(url) {
var xhr = createCORSRequest('GET', url);
if (!xhr) {
console.log('CORS not supported');
return;
}
// 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;
}
Ex.
readXml('http://hydra.cnet.se:44441/services/catalogue/actions')