har*_*ish 6 soap wsdl web-services node.js strong-soap
我正在使用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 ??
});
Run Code Online (Sandbox Code Playgroud)
我不确定如何strong-soap运作.但是,我有一些SOAP使用node-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);
});
});
Run Code Online (Sandbox Code Playgroud)
让我们使用以下示例 SOAP 服务:
通过主机名/域名(WhoIS)获取域名注册记录
要从代码中判断,您希望使用本地可用的.wsdl文件,因此保存它:
mkdir wsdl && curl 'http://www.webservicex.net/whois.asmx?WSDL' > wsdl/whois.wsdl
Run Code Online (Sandbox Code Playgroud)
现在让我们使用以下代码来查询它:
'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));
});
});
Run Code Online (Sandbox Code Playgroud)
它将产生一些有意义的结果。
WSDL.open您尝试使用的是用于处理 WSDL 结构的
将 WSDL 加载到树形形式中。遍历 WSDL 树以获取绑定、服务、端口、操作等。
您不一定需要它来调用服务
| 归档时间: |
|
| 查看次数: |
1793 次 |
| 最近记录: |