Created
April 4, 2014 16:39
-
-
Save darrenparkinson/9978397 to your computer and use it in GitHub Desktop.
Simple node.js script to request details of a line using Communications Manager AXL API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require("https"); | |
var authentication = 'username:password'; | |
var headers = { | |
'SoapAction':'CUCM:DB ver=9.1', | |
'Authorization': 'Basic ' + new Buffer(authentication).toString('base64'), | |
'Content-Type': 'text/xml; charset=utf-8' | |
} | |
var soapBody = new Buffer('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:axl="http://www.cisco.com/AXL/API/9.1">' + | |
'<soapenv:Header/>' + | |
'<soapenv:Body>' + | |
'<axl:listLine>' + | |
'<searchCriteria>' + | |
'<pattern>2001</pattern>' + | |
'</searchCriteria>' + | |
'<returnedTags>' + | |
'<pattern/>' + | |
'<description/>' + | |
'<usage/>' + | |
'<routePartitionName/>' + | |
'</returnedTags>' + | |
'</axl:listLine>' + | |
'</soapenv:Body>' + | |
'</soapenv:Envelope>'); | |
var options = { | |
host: '192.168.7.41', // The IP Address of the Communications Manager Server | |
port: 443, // Clearly port 443 for SSL -- I think it's the default so could be removed | |
path: '/axl/', // This is the URL for accessing axl on the server | |
method: 'POST', // AXL Requires POST messages | |
headers: headers, // using the headers we specified earlier | |
rejectUnauthorized: false // required to accept self-signed certificate | |
}; | |
// Doesn't seem to need this line, but it might be useful anyway for pooling? | |
options.agent = new https.Agent(options); | |
var req = https.request(options, function(res) { | |
console.log("status code = ", res.statusCode); | |
console.log("headers = " , res.headers); | |
res.setEncoding('utf8'); | |
res.on('data', function(d) { | |
console.log("Got Data: " + d); | |
}); | |
}); | |
req.write(soapBody); | |
req.end(); | |
req.on('error', function(e) { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment