我正在使用strong-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 ??
});
答案 0 :(得分:7)
我不确定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);
});
});
答案 1 :(得分:3)
让我们使用以下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
是meant for使用WSDL结构
将WSDL加载到树形式中。遍历WSDL树到达 绑定,服务,端口,操作等。
您不一定需要它来呼叫服务