1

请参阅下面的 TL;DR!

使用 node-soap 使用 WSDL 时遇到问题。我已经尝试过使用其他 WSDL(在网上找到的示例)并且它们工作得很好——但是,对于这个特定的,我遇到了无数的问题。我正在使用soap-as-promised,它使用node-soap 模块。它应该是无关紧要的。

var soap = require('soap-as-promised');
var url = 'https://test.ipg-online.com/ipgapi/services/order.wsdl';

var apiCall = exports.apiCall = function () {
        console.error("test");
        soap.createClient(url, { wsdl_options: { cert: '/path/to/cert.pem', key:'/path/to/key.key' } } )
        .then(function(client) {
            console.error(client);
            client.describe();
        })
        .catch(function(error) {
            console.error(error);
        });

    }

这是我现在使用的代码,但这绝对是不对的。它返回以下错误(我的证书和私钥的路径是正确的):

[错误:错误:0906D06C:PEM 例程:PEM_read_bio:没有开始行]

根据文档,我似乎应该使用 client.setSecurity 进行 SSL 通信:

    client.setSecurity(new soap.ClientSSLSecurity(
    '/path/to/key'
    , '/path/to/cert'
    , {/*default request options*/}
  ));

但是,如果我这样做,并忽略 wsdl_options,客户端将在回调中返回为未定义,不允许我运行任何函数,包括 setSecurity 函数。我认为它必须是两者的组合,但我不知道什么组合。

TL;DR尝试使用 node-soap 使用 WSDL;此 WSDL 需要证书和私钥,以及使用用户名/密码进行身份验证。使用 node-soap 执行此操作的过程是什么?我是否必须安装证书(我在 CentOS 上),然后以某种方式引用它们?

任何帮助都非常感谢 - 如果您熟悉该过程,即使使用另一个库,请加入!谢谢 :)

编辑:固定!对于其他有类似问题的人,代码如下:

soap.createClient(url, { wsdl_options: { cert: fs.readFileSync('/path/to/cert.pem'), key: fs.readFileSync('/path/to/key.key'), passphrase: 'password' } } )
4

0 回答 0