I’m trying an example to test a SOAP web service. It’s working for me except that when I try to display the JSON result using xml2js, I get ‘undefined’ ‘result’ variable. I need to get past this, to do next step to extract a couple of tag values to make another request. Anything I’m doing wrong in parsing?
function callback(error, response, body) {
//Log status code to Synthetics console.
console.log('HTTP Status Code: ’ + response.statusCode);
console.log('HTTP Response: ’ + response);
console.log('HTTP Response Body: ’ + body);
//Verify endpoint returns 200 (OK) response code.
assert.ok(response.statusCode == 200, ‘Expected 200 OK response’);
// Parse SOAP XML
var xml2js = require('xml2js');
var parser = new xml2js.Parser({explicitArray: false, trim: true});
console.log('XML response body: ' + response.body)
var jsResult = parser.parseString(response.body, (err, result) => {
console.log('JSON response body: ' + result);
console.dir(result);
});
// Issue a cancellation request
//Log end of script.
console.log("End reached");
}
Thanks,
Noel