1

I am fairly new to nodejs, but i have some working experience in APIs, I can work with REST. But SOAP is a bit tricky.

I would like to consume a SOAP web service through nodejs. I am using soap-npm

In my server.js file i have the following script - im not getting any errors - it runs...but

const soap = require('soap');
const url = 'http://ws.dev.freepaid.co.za/airtimeplus/?wsdl';
const args = { user: ****, pass: '****' };

soap.createClient(url, function(err, client) {

  client.fetchProducts(args, function(err, result) {

         if(err) 
         console.log("error:", err)
         else 
         console.log(result);
  })
}); 

In the terminal after running command 'node server.js', I get the following response...

{ 
reply: {
attributes: { 'xsi:type': 'tns:fetchProductsOut' },
status: { attributes: [Object], '$value': 0 },
errorcode: { attributes: [Object], '$value': '110' },
message: { attributes: [Object], '$value': 'request not defined' },
balance: { attributes: [Object], '$value': 0 },
products: { attributes: [Object] } 
    }
}

From this point, i'm not sure how to handle it.

What do I do in order to consume an operation?

In the WSDL, fetchProducts is an operation that will take in two params 'user' & 'password'.

I can run this operation in SOAP UI and POSTMAN, i get the responses i want. But i need to get these same responses in node.

How to?

eol
  • 23,236
  • 5
  • 46
  • 64

0 Answers0