Parsing SOAP XML response in Synthetics API test

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

Hey @noel.fuentes - New Relic staff cannot assist with writing Synthetics scripts, with that said, I have done some searching and I found a similar post here: Retrieve Value from SOAP response - Which links to a Selenium solution from Stack Overflow. Hopefully that helps you, and if not, I am sure there are others in the community who can assist troubleshooting your script. :slight_smile:

1 Like

no veo solucion a este problema aun por favor tengo el mismo problema

Hi @dyanez1, as my colleague Ryan mentioned, we do not offer support for writing Synthetics scripts. I would advise reading through the post that Ryan shared for some direction but hopefully someone on the community will be able to offer some guidance.

Also, just to clear any confusion, we only offer support in English. Just wanted to let you know in case there is a potential language barrier.