Skip to Content
0
Jul 07, 2020 at 09:36 PM

401 Not Authorised error while consuming soap service from nodejs soap client

323 Views Last edit Jul 07, 2020 at 10:56 AM 2 rev

Hi,

I am consuming SAP soap service from within nodejs using soap client. I tried the following code but got the 401 not authorized error. Can anyone help what is the mistake I am doing ? From SoapUI it is working fine with Basic Authentication. Here is my code:

const soap = require('soap');
const url = 'http://somedomain.com:8000/sap/bc/srt/rfc/sap/zint_customer_master_1/100/zint_customer_master_1/zint_customer_master_1';

const options = {
wsdl_header: {
'Authorization': 'Basic ' + Buffer.from('myuser:mypass').toString('base64')
}
}
soap.createClient(url, options, function (err, client) {
if (err) {
console.log(err)
} else {
console.log("Client established successfully")
}
});