【问题标题】:Consuming DynamicsNAV WebService with Node.JS node-soap使用 Node.JS node-soap 使用 DynamicsNAV WebService
【发布时间】:2015-08-14 11:03:39
【问题描述】:

我想通过一个小的 node.js 应用程序使用 Microsoft Dynamics NAV 2009 中的 WebService。服务本身运行良好,我将它与 c# 应用程序 一起使用,现在我想将数据输入到我的 nodejs/expressjs 应用程序中,但是,我总是得到Invalid WSDL URL一条错误消息。

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

现在我尝试按照文档通过正常和基本身份验证与 node-soap 连接,但每次我收到 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);
    });

这是我得到的回应:

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

【问题讨论】:

  • 经过一点调试,我发现我必须发送一个 ntml/negotiate 标头而不是基本的 auth 标头。我将尝试使用 node-soap 来完成它以发送协商标头,然后相应地编辑/回答这个问题
  • 可以使用httpntlm客户端,这里有一个完整的例子:stackoverflow.com/a/68823338/10030693

标签: node.js soap


【解决方案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);
    });

  })

});

【讨论】:

  • SPNEGO with node 可以使用 kerberos 模块。请参阅此要点:gist.github.com/dmansfield/c75817dcacc2393da0a7
  • 好的,谢谢。我确实知道 SPNEGO 是可能的,但我没有让它正常工作,所以我使用 NTLM 来代替现在至少取得任何进展。到目前为止,与 NTLM 的连接工作正常,因为 DynamicsNAV 在标准方面有点挑剔,我很高兴它能正常工作。但我会在几天后再次尝试 SPNEGO。感谢您的回复。
  • @Ello:你给出的例子对你有用吗?因为当我尝试使用此代码时,它在 nodeJS 上给了我一些错误,例如,提供的调用不是来自 httpntlm 库的回调。
  • @Ello:另外,您能告诉我,您为 Dynamics 登录设置了哪种身份验证类型? Windows 或 UserName 或 NavUserPassword 或 AccessControlService?
  • 我使用 nav/mssql 服务器分配的相应用户名/密码凭据。从未尝试过 Windows 身份验证。我仔细检查过,是的,基本上这是我正在运行的代码,除了 console.log 被替换为 client.ReadMultiple (或你想要调用的方法)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-04-07
  • 2016-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多