我正在使用强soap节点模块,我想调用webservice,我有wsdl文件。
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 ??
});发布于 2018-02-17 00:16:49
我不确定strong-soap是如何工作的。但是,我有一些使用node-soap的SOAP实现
基本上,node-soap包使用Promises来保持请求的并发性。
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);
});
});发布于 2018-02-13 02:18:02
让我们使用下面的sample SOAP service
按主机名/域名(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结构的meant for。
将WSDL加载到树形结构中。遍历WSDL树以获取绑定、服务、端口、操作等。
您不一定需要它来调用服务
https://stackoverflow.com/questions/45535389
复制相似问题