4

我正在尝试使用 node-soap 客户端向 wdsl 发送请求

这是我的代码:

var url = 'https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl';

            soap.createClient(url, function(err, client) {

                var today = new Date();
                var params = {
                    terminalId: "1926577",
                    userName: "test2",
                    userPassword: "test1",
                    orderId: receipt.recieptId + "",
                    amount: parseInt(receipt.overal_price) + "",
                    localDate: today.format('ymd'),
                    localTime: today.format('His'),
                    additionalData: "Customer No: 15220",
                    callBackUrl: "http://test.ir/pay/verify",
                    payerId: parseInt(receipt.user) + ""
                };

                console.log(params);


                client.bpPayRequest(params, function(err, result) {
                    if (err) {
                        throw err;
                    }
                    console.log(result);
                });

并且从 wsdl 返回此错误:

错误:soap:Client:发现意外的包装元素 bpPayRequest。
预期 { http://interfaces.core.sw.bps.com/ }bpPayRequest。

似乎 ns1 没有作为前缀添加到

xml 请求中的节点

我将模块更新为 v0.13.0 并添加了以下内容:

used this code :
var options = {
                ignoredNamespaces: {
                    namespaces: [],
                    override: true
                }
            }

还是一样的错误:(

临时修复 将此添加到 node-soap 的 wsdl.js 文件的第 1496 行:

name = 'ns1:'+name;
4

4 回答 4

4

用这个:

var options = {
    overrideRootElement: {
        namespace: 'ns1'
    }
};

它适用于版本 0.16

于 2016-09-24T15:53:34.367 回答
2

与 node-soap 的 0.14.0 版本有同样的问题。
切换回 0.11.0 为我解决了这个问题。

于 2016-05-06T18:27:33.540 回答
0

从 0.16.0 版开始,建议ignoredNamespaces再次重置作品的解决方案:

var options = {
  ignoredNamespaces: {
    namespaces: [],
    override: true
  }
}
于 2016-08-02T07:05:01.527 回答
0

在 0.16.0 版本中,您应该更改第 1530 行:

WSDL.prototype.objectToDocumentXML = function(name, params, nsPrefix, nsURI, type) {
   var args = {};
   args["ns1:" + name] = params; // instead of args[name] = params;
   ...
于 2016-08-14T08:57:39.587 回答