在 Node.js SOAP 客户端中设置授权 [英] Setting Authorization in Node.js SOAP Client

查看:221
本文介绍了在 Node.js SOAP 客户端中设置授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 Node.js 中的 SOAP 客户端访问 WSDL 服务.我使用了 soap 节点模块.但是我找不到任何文档来设置用户名和密码.我不打算创建 SOAP 服务器,我只想要类似于 PHP 的 SoapClient 的 SOAPClient,使用它我应该能够访问 WSDL 服务.

I want to access a WSDL service through SOAP Client in Node.js. I used soap node module. But I can't able to find any documentation to set username and password. I'm not going to create SOAP server, I just want SOAPClient which is similar to PHP's SoapClient, using which I should able to access the WSDL service.

更新:

我已经分叉并定制了源代码以支持此功能https://github.com/sincerekamal/node-soap

I had forked and customised the source to support this feature https://github.com/sincerekamal/node-soap

推荐答案

您可以像这样提供用户名和密码:

You can provide username and password like this:

var soap = require('soap');
var url = 'your WSDL url';
var auth = "Basic " + new Buffer("your username" + ":" + "your password").toString("base64");

soap.createClient(url, { wsdl_headers: {Authorization: auth} }, function(err, client) {
});

(源自 https://github.com/vpulim/node-soap/issues/56,谢谢Gabriel Lucena https://github.com/glucena)

这篇关于在 Node.js SOAP 客户端中设置授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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