2016-08-25 48 views
0

首先我得到了pfx證書,其中一個導出到pem和密鑰與openssl(如果這可能是一個問題)。我想使用client.setSecurity(new soap.ClientSSLSecurit()),但我得到客戶端未定義。Nodejs,肥皂,回調是不是一個功能

我的代碼是這樣的:

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 米哈

回答

2

你的論點是不正確的。請更正如下:

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(); 

}); 
+0

THX這個:)我固定的,但現在越來越: client.describe(); ^ TypeError: Cannot read property 'describe' of undefinedat D:\web\mobile\app.js:26:8 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 如何知道哪裏是問題?如果問題與證書或其他問題有關,如何進行調試? tnx – user2017319

+0

@ user2017319檢查'err'對象 –

+0

tnx @Ebrahim Pasbani爲您快速回復。 這是什麼錯誤顯示:錯誤:連接ETIMEDOUT xxx.xxx.xxx.xxx:443在位於exports._exceptionWithHostPort(util.js:1030:20)上Object.exports._errnoException(util.js:1007:11)在TCPConnectWrap .afterConnect [as oncomplete](net.js:1080:14)8月25日10:07:36 - [nodemon]應用程序崩潰 - 在啓動之前等待文件更改.. 這是重新設置ssl還是別的? tnx – user2017319