使用带有Node.JS node-soap的DynamicsNAV WebService

我想通过一个小型的node.js应用程序使用Microsoft Dynamics NAV 2009中WebService 。 服务本身工作正常,我正在使用一个C#应用程序 ,现在我想要获取数据到我的nodejs / expressjs应用程序,但是,我总是得到Invalid WSDL URL作为错误消息。

这是我的浏览器看到它的WSDL。

在这里输入图像说明

现在,我试图通过正常的和基本的身份validation来跟随node-soap连接,但是每次我得到一个Invalid WSDL URL错误。

以下是我为testing连接尝试的方法:

  var url = "http://navsrv:7047/DynamicsNAV2/WS/Produktiv/Page/WDCETA"; var auth = "Basic " + new Buffer("*********" + ":" + ****************").toString("base64"); soap.createClient(url, function(err, client) { console.log('Without basic out:'); if (err) { console.log('[ERROR] -> '); console.log(err); } console.log(client); }); soap.createClient(url, {wsdl_headers: {Authorization: auth} }, function(err, client) { console.log('With basic out:'); if (err) { console.log('[ERROR] -> '); console.log(err); } console.log(client); }); 

这是我得到的回应:

 Without basic out: [ERROR] -> [Error: Invalid WSDL URL: http://navsrv:7047/DynamicsNAV2/WS/Produktiv/Page/WDDCETA Code: 401 Response Body: ] undefined With basic out: [ERROR] -> [Error: Invalid WSDL URL: http://navsrv:7047/DynamicsNAV2/WS/Produktiv/Page/WDDCETA Code: 401 Response Body: ] undefined 

事实certificate,从DyanmicsNAV构buildHTTP-Server需要SPNEGO或NTLM身份validation。 在尝试使用nodejs / node-soap创build正确的SPNEGO请求之后,我closures了SPNEGO并启用了NTLM。

在soap-ntlm和httpntlm的帮助下,我可以检索wsdl。

这是一些testing代码,我如何设法检索WSDL文件。 现在我很高兴,但我想当涉及到调用函数会有一些其他的问题:)

 var soap = require('soap-ntlm'); var fs = require('fs'); var httpntlm = require('httpntlm'); var url = 'http://navsrv:7047/DynamicsNAV2/WS/Produktiv/Page/WDCETA'; var username = '*******'; var password = '***********'; httpntlm.get({ url: url, password: password, username: username }, function(err, wsdl) { if (err) { console.log('ERR: -> '); console.log(err); return; } fs.writeFile('wsdl_cache/WDCETA.wsdl', wsdl.body, function() { soap.createClient(__dirname + '/wsdl_cache/WDCETA.wsdl', function(err, client) { if (err) { console.log('SOAP ERR: ->'); console.log(err); return; } client.setSecurity(new soap.NtlmSecurity(username, password)); console.log(client); }); }) });