Ryan Garde
Ryan Garde

Reputation: 922

How to properly use nodejs soap

My code looks like this:

soap.createClient(url, function(err, client) {
  if(err) {
     res.status(500);
     return res.send(err);
  }

  client.GetMemberPIN({pUserName: 'r'}, function(error, result) {
    if(error) {
      res.status(500);
      return res.send(error)
    }
    return res.send(result);
  });
});

I tried running it and it returns this error?

{
  "code": "ECONNRESET"
}

Upvotes: 1

Views: 434

Answers (1)

Terry Lennox
Terry Lennox

Reputation: 30675

I'd suggest testing a few things:

Here's a working example testing against a public server, this might help you to understand what could be going wrong with your code:

const soap = require('soap');
const url = 'https://www.crcind.com/csp/samples/SOAP.Demo.CLS?WSDL=1';
const args = { id: 1 };

soap.createClient(url, function(err, client) {
    if (err) {
        console.error("An error occurred creating client:", err);
        return;
    } 

    client.FindPerson(args, function(err, response) {
        if (err) {
            console.error("An error occurred calling client.FindPerson:", err);
            return;
        }
        console.log("client.FindPerson: response:", response);
    });
});

Upvotes: 1

Related Questions