使用node-soap通过Node.js中的Soap发送参数 [英] Sending arguments via Soap in Node.js using node-soap

查看:213
本文介绍了使用node-soap通过Node.js中的Soap发送参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用NodeJS,并且我正在使用 milewise的节点 - 与SOAP服务进行交流。肥皂。我使用基本的电子邮件地址验证SOAP API作为我的测试用例。

I am just getting started with NodeJS and I digging into talking to a SOAP service using milewise's node-soap. I am using a basic email address validation SOAP API as my test case.

我似乎不理解格式化参数列表的正确方法。

I don't seem to understand the correct way to format my arguments lists.

我的SOAP客户端代码:

My SOAP client code:

    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:"my@emailaddress.com"}, function(err, result){
            console.log(result);
    });
});

client.describe()命令告诉我API如何格式化其输入,以及它如何将返回其输出。这就是说:

The client.describe() command tells me how the API would like its input formatted, and how it will return its output. This is what is says:

{input:{'request []':'xs:string'},
输出: {'ValidateResult []':'xs:boolean'}}

但是当我将参数作为对象发送时: {request:my@emailaddress.com}

However when I send the arguments as an object: {request:"my@emailaddress.com"}

我觉得我的问题在于我如何定义arguments对象。 .. 中的括号请求[] 是什么意思?

I feel like my problems lies in how I am defining the arguments object...what do the brackets in request[] mean?

推荐答案

如果在请求参数上添加命名空间,它应该可以工作。
这是一个示例代码。

It should work, if you add namespace on request argument. This is a sample code.

var soap = require('soap');

var url = "http://www.restfulwebservices.net/wcf/EmailValidationService.svc?wsdl";

var args = {"tns:request":"my@emailaddress.com"};

soap.createClient(url, function(err, client){
    client.EmailValidationService.BasicHttpBinding_IEmailValidationService.Validate(args, function(err, result){
            if (err) throw err;
            console.log(result);
    });
});

然而,它返回访问被拒绝。

However, it returns "Access is denied".

我使用soapUI来测试这个Web服务,它会返回相同的结果。

I use soapUI to test this web service, it returns the same result.

我尝试了另一个Web服务,它可以工作。

I try another web service, and it works.

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);
    });
});

这篇关于使用node-soap通过Node.js中的Soap发送参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆