标签: node-soap

在 Node-soap (node.js) 中发送带有数组的请求

我正在使用 Nodejs 和 Node-Soap 与 Web 服务进行通信。但我似乎无法获得将参数传递给服务的正确语法。

文档说我需要发送一个包含字段 uuid 及其值的数组。

这是我从网络服务所有者那里得到的 PHP 代码作为示例

$uuid = "xxxx";

    $param = array("uuid"=>new SoapVar($uuid,
    XSD_STRING,
    "string", "http://www.w3.org/2001/XMLSchema")
    )
Run Code Online (Sandbox Code Playgroud)

这是我在节点服务器中使用的代码

 function getSoapResponse()
{
    var soap = require('soap');
      var url = 'http://live.pagoagil.net/soapserver?wsdl';
      var auth = [{'uuid': 'XXXXXXXXX'}];

      soap.createClient(url, function(err, client) {
      client.ListaBancosPSE(auth, function(err, result) 
      {
          console.log(result);
          console.log(err);
      });
  });
Run Code Online (Sandbox Code Playgroud)

有了这个我得到了错误的 xml 错误

var auth = [{'uuid': 'XXXXXXXXX'}];
Run Code Online (Sandbox Code Playgroud)

或者

var auth = [["uuid",key1],XSD_STRING,"string","http://www.w3.org/2001/XMLSchema"];
Run Code Online (Sandbox Code Playgroud)

这样我得到的响应是“用户 ID 为空”(uuid)

 var auth = {'uuid': 'XXXXXXXXX'};
Run Code Online (Sandbox Code Playgroud)

有什么建议么?

javascript node.js node-soap

2
推荐指数
1
解决办法
1万
查看次数

使用node-soap客户端通过代理调用SOAP API

我正在使用node-soap模块,它工作正常,除非我在代理后面工作.我无法找到设置该代理的方法,因此我可以请求API.

soap.createClient(url, function(err, client) {
      client.MyFunction(args, function(err, result) {
          console.log(result);
      });
});
Run Code Online (Sandbox Code Playgroud)

它写在文档中:

The options argument allows you to customize the client with the following properties:

request: to override the request module.
httpClient: to provide your own http client that implements request(rurl, data, callback, exheaders, exoptions).
Run Code Online (Sandbox Code Playgroud)

这是要走的路吗?

soap soap-client node.js node-soap

2
推荐指数
1
解决办法
4153
查看次数

如何使用 node-soap 查看请求正文

我有一些示例代码,如下所示:

var soap = require('soap');
var url  = "http://www.example.com?wsdl";

var soapHeader = "<AuthHeader>...</AuthHeader>";

soap.createClient(url, function(err, client){
  client.addSoapHeader(soapHeader);

  var args = {
       'arg1': 1
    }
  };

  client.SomeMethod(args, function(err, result){
   if(err){

    throw err;

   }
   console.log(JSON.stringify(result));
  });
});
Run Code Online (Sandbox Code Playgroud)

问题是由于我传递的标头或参数不正确,请求失败。如果我可以看到整个请求正文,那么调试会容易得多。这是怎么做到的?

soap node.js node-soap

2
推荐指数
1
解决办法
2009
查看次数

Node soap ClientSSLSecurityPFX - 403 Forbidden

我正在尝试使用node-soap连接到 SOAP 服务,但获取403 - Forbidden.

我有一个 pfx 文件和一个密码,我正在尝试:

var pfx = fs.readFileSync(path.join(__dirname, 'folder', 'my.pfx')); // pfx file is in the relative path './folder/my.pfx'
var password = 'mypassword';
var options = {
  strictSSL: true,
  rejectUnauthorized: false,
  hostname: myUrl,
  forever: true
};
var security = new soap.ClientSSLSecurityPFX(pfx, password, options);
var url = 'https://theservice.com/ApplicationService.svc?singleWsdl';
soap.createClient(url, function (err, client) {
  console.log(err);
  console.log(client);
  client.setSecurity(security);
});
Run Code Online (Sandbox Code Playgroud)

但我得到 403:

[Error: Invalid WSDL URL: https://theservice.com/ApplicationService.svc?singleWsdl

 Code: 403

 Response Body: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML …
Run Code Online (Sandbox Code Playgroud)

soap-client pfx node.js http-status-code-403 node-soap

0
推荐指数
1
解决办法
1212
查看次数