strong-soap: call service method over https

1.1k Views Asked by At

I am trying to call a SOAP service using the strong-soap node.js library. Although I did set the client security to ClientSSLSecurity, I am getting an error when invoking a method on the client:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"

How can I tell stong-soap to use https?

Here is my code so far:

"use strict";
 
var soap = require('strong-soap').soap;
var constants = require('constants');
var url = 'http://www.caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl';
var WSDL = soap.WSDL;
var options = {};
WSDL.open(url,options,
  function(err, wsdl) {
    if (err) {
      console.log(err);
      return;
    }

    var clientOptions = {
      WSDL_CACHE : {
        caqhcorewsdl: wsdl
      }
    };
    soap.createClient('caqhcorewsdl', clientOptions, function(err, client) {
      if (err) {
        console.log(err);
        return;
      }
      else {
        client.setSecurity(new soap.ClientSSLSecurity(
            'rob.keystore'
          , 'cert.pem'
          , {
            strictSSL: true,
            secureOptions: constants.SSL_OP_NO_TLSv1_2
          }
        ));
        if(err) {
            console.error(err);
            return;
        }
        else {
          console.log('success!');
          client.RealTimeTransaction({name: 'value'}, function(err, result, envelope, soapHeader) {
            if(err) {
              // ERROR IS THROWN HERE:
              console.error(err);
              return;
            }
            else {
              console.log('success!');
            }
          });
        }
      }
    });
});

Thanks!

Rob G

1

There are 1 best solutions below

0
On

replace the following line with this one:

var url = 'https://www.caqh.org/SOAP/WSDL/CORERule2.2.0.wsdl';