1

I am trying to create a Soap Client in my NodeJs application to call API to SOAP web service with url: https://example.com/service?wsdl

If its a soap webservice then I get the below error. It would be really great if you guys could guide me in the right direction.

I always get the below error: failed to handle request, err: Error: connect ETIMEDOUT xx.xx.xx.xx:80, result:undefined

I dont know how is DNS always resolved with port 80 instead of 443. Below is my soap-client code: using the node-module: https://github.com/vpulim/node-soap (v0.19.2)

const soap = require('soap');
const config = require('./config');
const console = require('stringify-log').console;

const options = {
  disableCache: false,
  wsdl_headers: { connection: 'keep-alive' },
};

function requestHandle(data) {
  return new Promise(resolve => {
    soap.createClient(config.url, options, function(err, client) {
      // Do ở đây err = {} => if true -> trả về cant connect
      console.log('[PREFIX]',`[ERROR] request to web service, url: ${config.url}, ${data}`)
      if (err) {
        console.log('[PREFIX]','[ERROR] failed to create client ', options, err)
        return resolve({ status: 0, error: err });
      }
      client.requestHandle({ input: JSON.stringify(data) }, function(
        err,
        result
      ) {
        if (err) {
          console.log('[PREFIX]',`[ERROR] failed to handle request: data: ${data}, err: ${err}, result:${result}`)
          return resolve({ status: 0, error: err });
        }
        resolve({ status: 1, data: result });
      });
    });
  });
}

Thanks in advance.

Please help me find mistake to resolve this problem

TanLuan
  • 11
  • 1

0 Answers0