我刚刚开始使用 NodeJS,并且正在深入研究使用 SOAP 服务milewise 的节点肥皂 https://github.com/milewise/node-soap#readme。我使用基本的电子邮件地址验证 SOAP API 作为我的测试用例。
我似乎不明白格式化参数列表的正确方法。
我的 SOAP 客户端代码:
var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl";
soap.createClient(url, function(err, client){
console.log(client.describe().EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate);
client.Validate({result:"[email protected] /cdn-cgi/l/email-protection"}, function(err, result){
console.log(result);
});
});
client.describe() 命令告诉我 API 希望如何格式化其输入,以及如何返回其输出。这是这样说的:
{ input: { 'request[]': 'xs:string' },
output: { 'ValidateResult[]': 'xs:boolean' } }
但是,当我将参数作为对象发送时:{request:"[email protected] /cdn-cgi/l/email-protection"}
我觉得我的问题在于如何定义参数对象......括号中的内容是什么request[]
mean?
如果您在请求参数上添加名称空间,它应该可以工作。
这是示例代码。
var soap = require('soap');
var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl";
var args = {"tns:request":"[email protected] /cdn-cgi/l/email-protection"};
soap.createClient(url, function(err, client){
client.EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate(args, function(err, result){
if (err) throw err;
console.log(result);
});
});
但是,它返回“访问被拒绝”。
我使用soapUI来测试这个网络服务,它返回相同的结果。
我尝试了另一个网络服务,它有效。
var soap = require('soap');
var url = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl";
var args = {"tns:request":"GOOG"};
soap.createClient(url, function(err, client){
client.StockQuoteService.BasicHttpBinding_IStockQuoteService.GetStockQuote(args, function(err, result){
if (err) throw err;
console.log(result);
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)