How to use wsdl webservice through node js

I am using the strong-soap node module, which I want to do to call webservice, I have a wsdl file.

var soap = require('strong-soap').soap;
var WSDL = soap.WSDL;
var path = require('path');
var options = {};
WSDL.open('./wsdls/RateService_v22.wsdl',options,
  function(err, wsdl) {
    // You should be able to get to any information of this WSDL from this object. Traverse
    // the WSDL tree to get  bindings, operations, services, portTypes, messages,
    // parts, and XSD elements/Attributes.

    var service = wsdl.definitions.services['RateService'];
    //console.log(service.Definitions.call());
    //how to Call rateService ??
});
+6
source share
2 answers

I'm not sure how it works strong-soap. But I have some implementations SOAPusing node-soap

Basically, the package is node-soapused Promisesto save requests.

var soap = require('soap');
  var url = 'http://www.webservicex.net/whois.asmx?WSDL';
  var args = {name: 'value'};
  soap.createClient(url, function(err, client) {
      client.GetWhoIS(args, function(err, result) {
          console.log(result);
      });
  });
+6
source

Allows you to use the following SOAP service example :

Get a domain name registration record by host name / domain name (WhoIS)

, .wsdl, , :

mkdir wsdl && curl 'http://www.webservicex.net/whois.asmx?WSDL' > wsdl/whois.wsdl

:

'use strict';

var soap = require('strong-soap').soap;
var url = './wsdl/whois.wsdl';

var requestArgs = {
    HostName: 'webservicex.net'
};

var options = {};
soap.createClient(url, options, function(err, client) {
  var method = client['GetWhoIS'];
  method(requestArgs, function(err, result, envelope, soapHeader) {
    //response envelope
    console.log('Response Envelope: \n' + envelope);
    //'result' is the response body
    console.log('Result: \n' + JSON.stringify(result));
  });
});

. WSDL.open, , WSDL

WSDL . WSDL, , , , ..

+3

All Articles