var assert = require('assert');

var url = "http://name.somehost.com:8080/test/xmls";
var soapMsg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><WEBPartInquiryRequest><Envelope><BuyPartnerID>86</BuyPartnerID> <DocVersNum>1.0</DocVersNum><DocGenBy>WIT</DocGenBy></Envelope><RequestRouter><SellPartnerID>PAD08</SellPartnerID><CustNum>89</CustNum></RequestRouter><PartRequestAction><AskPayForm/><AskShipList/><ReturnAltLocInfo value=\"Always\"/><AskPriceTypes/></PartRequestAction><PartInquiryRequest><ItemDefaults><OrderType>Normal</OrderType><Vehicle><CatVehID/><Year>0</Year><Make/><Model/><Engine/><SpeclCond/></Vehicle></ItemDefaults><RequestItem><ID>1</ID><PartNum>1</PartNum><BuyerDesc/><MfgCode>AC</MfgCode><Qty>4</Qty></RequestItem></PartInquiryRequest></WEBPartInquiryRequest>";

var options = {
//Define endpoint URL.
url: url,
//Define body of POST request.
body: soapMsg,
//Define insert key and expected data type.
headers: {
// 'Content-Type': 'application/soap+xml;charset=UTF-8;action="http://www.webserviceX.NET/GetQuote"',
// 'Host': 'www.webservicex.net',
// 'Accept-Encoding': 'gzip,deflate',
// 'Connection': 'Keep-Alive'
'SOAPAction':'',
'charset':'utf-8',
'Content-Type':'text/xml',
'User-Agent':''
}
};

//Define expected results using callback function.
function callback(error, response, body) {
//Log status code to Synthetics console.
console.log(response.statusCode + " status code");
//Verify endpoint returns 200 (OK) response code.
assert.ok(response.statusCode == 200, 'Expected 200 OK response');
//Parse JSON received from Insights into variable.
//
var parseString = require('xml2js').parseString;
var XMLReSULT = response.body;
parseString(XMLReSULT, function (err, result) {
console.dir(result);
 
});
 
//Log end of script.
console.log("End reached");
}

//Make POST request, passing in options and callback.
$http.post(options, callback);
 

-----------------------

from

https://discuss.newrelic.com/t/creating-soap-request-using-the-api-scripting-language/28167