Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Created October 21, 2021 17:05
Show Gist options
  • Select an option

  • Save diegofcornejo/218447d09b4eb26ac52e366cd4e7c6dc to your computer and use it in GitHub Desktop.

Select an option

Save diegofcornejo/218447d09b4eb26ac52e366cd4e7c6dc to your computer and use it in GitHub Desktop.
Node request SOAP service
var request = require('request');
var order = {
"foo":"bar"
}
order = JSON.stringify(order);
var xml = `<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:api="https://diegocornejo.com/">
<soap:Header/>
<soap:Body>
<api:sendOrder>
<api:orderJSON>${order}</api:orderJSON>
</api:sendOrder>
</soap:Body>
</soap:Envelope>`;
request.post({
url: "http://xx.xx.xx.xx:1234/soap/service.asmx",
method: "POST",
headers: {
'Content-Type': 'application/soap+xml;charset=utf-8',
},
body: xml
},
function (error, response, body) {
if (error) {
console.log('error');
console.log(error);
} else {
console.log('body');
console.log(body);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment