I'm attempting to use the Node.js soap module to access the Unicommerce xml API. In soapUI, it functions properly. However, it is not included in the node application. I experience this error.
ERROR: {Error: Cannot parse response}.
var express = require("express");
var soap = require("soap");
var http = require('http');
var app = express();
var router = express.Router();
var username = "*********";
var password = "************";
var auth = "Basic " + new Buffer(username + ":" + password).toString("base64");// not working
var wsdlUrl = 'https://lensclues.unicommerce.com/services/soap/uniware16.wsdl?facility=01';
const Autentication = '<soapenv:Header>' +
'<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' +
'<wsse:UsernameToken wsu:Id="UsernameToken-D6BE484999DA5E97D4148483888689316">' +
'<wsse:Username>**********</wsse:Username>' +
'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">*******************</wsse:Password>'+
'<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">$$$$$$$$$$$</wsse:Nonce>'+
'<wsu:Created>2017-01-19T15:14:46.893Z</wsu:Created>'+
'</wsse:UsernameToken>'+
'</wsse:Security>' +
'</soapenv:Header>'
soap.createClient(wsdlUrl, function (err, soapClient) {
soapClient.addSoapHeader(Autentication);
const data = '<soapenv:Envelope xmlns:ser="http://uniware.unicommerce.com /services/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' + '<soapenv:Body>' +
'<ser:GetInventorySnapshotRequest>' +
'<ser:ItemTypes>' +
'<ser:ItemType>' +
'<ser:ItemSKU>LCSGDB555xD15165S4PURx124</ser:ItemSKU>' +
'</ser:ItemType>' +
'</ser:ItemTypes>' +
'<ser:UpdatedSinceInMinutes>600</ser:UpdatedSinceInMinutes>' +
'</ser:GetInventorySnapshotRequest>' +
'</soapenv:Body>' +
'</soapenv:Envelope>'
if (err) {
console.log("err", err);
}
soapClient.GetInventorySnapshot({
data
}, function (err, result) {
if (err) {
console.log("ERROR:", err);
}
else {
console.log("result", result);
}
});
The question is: How do I send the request and print the answer? Could you have any clues about this kind of issue?