且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用node-soap通过Node.js中的Soap发送参数

更新时间:2023-01-18 12:10:45

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

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