Using Node to call SOAP Web Service over https

前端 未结 2 1503
不知归路
不知归路 2021-02-10 20:53

I am trying to use node-soap https://github.com/vpulim/node-soap to call a web service but I am having trouble using the module with https.

In the code

2条回答
  •  暖寄归人
    2021-02-10 21:27

    For recommended solution - Provide root/intermediate certificates of CA to verify the remote certificates, try this-

    var request = require('request'); 
    var specialRequest = request.defaults({ ca: fs.readFileSync('ca.cert.pem') //path of CA cert file );
    
    var auth = "Basic " + new Buffer.from("myUsername:myPassword").toString("base64"); 
    var options = { wsdl_headers: { Authorization: auth }, request: specialRequest };
    
    soap.createClient(url, options, function (err, client) {
        client.myFunction(args, function (err, result) { 
            console.log(result);
        });
    });
    

提交回复
热议问题