Created
October 21, 2021 17:05
-
-
Save diegofcornejo/218447d09b4eb26ac52e366cd4e7c6dc to your computer and use it in GitHub Desktop.
Node request SOAP service
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 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