首先我获得了pfx certficate,将其导出为pem并使用openssl键入密钥(如果这可能是个问题)。我trid使用client.setSecurity(new soap.ClientSSLSecurit()),但后来我得到客户端未定义。
我的代码是这样的:
var soap = require('soap'),
fs = require('fs');
var url = 'tes.com';
var auth = "Basic " + new Buffer("user" + ":" + "password").toString("base64")
soap.createClient( url, {wsdl_options: {
cert: fs.readFileSync('cert/certificate.pem'),
key: fs.readFileSync('cert/certificate.key')
}
}, { wsdl_headers: {Authorization: auth} }, function(err, client) {
client.describe();
});
我收到此错误但不知道出了什么问题:
callback(err, wsdl && new Client(wsdl, endpoint, options));
^
TypeError: callback is not a function
at D:\web\mobile\node_modules\soap\lib\soap.js:50:5
at D:\web\mobile\node_modules\soap\lib\soap.js:33:16
at D:\web\mobile\node_modules\soap\lib\wsdl.js:2167:9
at Request._callback (D:\web\mobile\node_modules\soap\lib\http.js:114:14)
at self.callback (D:\web\mobile\node_modules\request\request.js:187:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (D:\web\mobile\node_modules\request\request.js:813:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
TNX 米哈
答案 0 :(得分:4)
你的论点不正确。请这样纠正:
soap.createClient( url, {wsdl_options: {
cert: fs.readFileSync('cert/certificate.pem'),
key: fs.readFileSync('cert/certificate.key')
},
wsdl_headers: {Authorization: auth} }, function(err, client) {
client.describe();
});