我想使用 node.js 小应用程序从 Microsoft Dynamics NAV 2009 中使用 WebService 。服务本身工作正常,我正在使用 c#application ,现在我想将数据导入我的 nodejs / expressjs 应用程序但是,我总是得到{{1} }作为错误消息。
这是我的浏览器看到的WSDL。
现在我尝试使用node-soap连接文档,通过普通和基本身份验证,但每次我收到Invalid WSDL URL
错误。
以下是我为测试连接尝试的方法:
Invalid WSDL URL
这是我得到的回应:
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);
});
答案 0 :(得分:1)
事实证明,DyanmicsNAV中的HTTP-Server构建需要SPNEGO或NTLM作为身份验证。在尝试使用nodejs / node-soap创建正确的SPNEGO请求后,我关闭了SPNEGO并启用了NTLM。
在soap-ntlm和httpntlm的帮助下,我可以检索wsdl。
这是一些测试代码,我可以设法检索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);
});
})
});