1

我正在使用node-soaplib 来创建一个肥皂客户端。在资产净值方面,凭证类型为Windows。当我试图从 访问NAV Soap Web ServiceNodeJS,它给了我Error:401(拒绝访问)。这是我在我的应用程序中使用的代码。

var soap = require("soap");
var url = "http://<url>"; // This is accessible from browser.

soap.createClient(url, function (err, client) {
        if (err) { console.log(err); }
        else {
            console.log(client.describe());
        }
    });  
4

1 回答 1

1

所以我只是通过这个来集成我们的 ERP 软件和 NAV(现在实际上称为 Dynamics365 Business Central),并认为我将把我所做的事情留在这里来帮助人们。所以仅供参考,我在 NAV 14.0 上做了这个。

var soap = require('soap');
var url = 'http://localhost:7047/{INSTANCE}/WS/{COMPANY}/Codeunit/{CODEUNITNAME}';

var security = new soap['NTLMSecurity']({
  username: NAVUSERNAME,
  password: NAVUSERPASSWORD,
  domain: DOMAIN',
  negotiate: true
});

const wsdl_headers = {}, wsdl_options = {};
security.addHeaders(wsdl_headers);
security.addOptions(wsdl_options);

return soap.createClientAsync(url, { wsdl_headers, wsdl_options })
.then( 
  (client) => {
    client.setSecurity(security) 
    return client;
  }
).then((client) => {
  return client.FunctionNameAsync({params});
})

这将验证 wsdl 请求和您尝试访问的 SOAP 服务。当我第一次尝试这个时,我得到了错误Couldn't find NTLM in the message type2 comming from the server。这是因为我安装的 NAV 默认关闭 NTLM 身份验证。我不知道关闭此功能后期望什么身份验证方法。您可以通过服务器管理器启用此功能: 在此处输入图像描述

之后重新启动实例,您的身份验证将有望工作。希望这对其他人有帮助。

于 2019-05-31T13:33:53.167 回答