Snippets
Useful snippets of code given as examples to help with various scripting needs.
Scripted SOAP Service
(function scriptedWebServiceOperation(request, response) {
var helper = new x_snd_eb.SoapHelper('api_name'); // the API name of the Unifi Process
var xml = helper.processRequest(soapRequestXML);
response.soapResponseElement = snd_eb_util.getSoapResponseElement(xml);
})(request, response);Removing Namespaces
(function scriptedWebServiceOperation(request, response) {
var helper = new x_snd_eb.SoapHelper('api_name'); // the API name of the Unifi Process
// specify the namespaces to strip
var request_xml = removeNamespacePrefix(soapRequestXML, 'urn:Unifi_RemedyCase_Service');
var response_xml = helper.processRequest(request_xml);
response.soapResponseElement = snd_eb_util.getSoapResponseElement(response_xml);
})(request, response);
function removeNamespacePrefix(payload, namespace) {
var matcher = new RegExp("xmlns(:[a-z0-9]+)?=[\"']" + namespace);
var match = payload.match(matcher);
var replacer;
payload = String(payload);
if (match) {
payload = payload.replace(new RegExp("xmlns" + match[1]), 'xmlns');
replacer = new RegExp("(</?)" + match[1].substr(1) + ":", "g");
payload = payload.replace(replacer, '$1');
}
return payload;
}Scripted REST API
Poll Requests
Bond location and data
Was this helpful?
