I have this function on NodeJS:
const easysoap = require('easysoap');
function request(action, inputField) {
const clientParams = {
host: 'https://example.com/demo/service',
path: '/service.asmx',
wsdl: '/service.asmx?WSDL',
headers: [{
name: 'SOAPAction',
value: `service/GetNumber`
}]
};
const clientOptions = {
secure: false
};
const soapClient = easysoap.createClient(clientParams, clientOptions);
soapClient.call({
method: "GetNumber",
attributes: {
xmlns: 'service'
},
params: {
Credentials: {
UserName: 'Me',
Password: 'mypass'
}
}
})
.then((callResponse) => {
return callResponse.data.GetNumberResponse.number;
})
.catch((err) => {
console.log('Got an error making SOAP call: ', err);
});
}
export default { request };
The request is working well if invoked via curl as a web service. However, transformed as a function I always get error TypeError: Cannot read property 'then' of undefined when running the test below:
describe('# GetInvoiceDetailsbyInvoiceNumber', () => {
it('should return some valid number', (done) => {
soap.request()
.then((output) => {
console.log(output);
expect(output).to.deep.equal(expectedOutput);
done();
})
.catch(done);
});
});
What is wrong?
via Arturo
No comments:
Post a Comment