1 安装模块
npm install soap
客户端连接
const Xml2js = require('xml2js');
const Parser = new Xml2js.Parser({explicitArray: false, ignoreAttrs: false});
const Soap = require('soap');
var args = {name: 'value'};
var url = 'http://example.com/wsdl?wsdl';
//建立连接
Soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
//解析xml数据
Parser.parseString(result.out, function (err, data) {
if (err) console.log(err);
resolve(data);
});
});