用于从node.js soap客户端调用SOAP Web服务的NTLM身份验证?

时间:2016-03-30 21:00:14

标签: node.js soap wsdl soap-client ntlm

我有一个运行express.js框架的node.js应用程序试图使用需要身份验证的SOAP Web服务。

如果我将此特定WSDL的URL输入浏览器,则会弹出登录对话框。输入我的用户凭据后,我将进入WSDL。但是我如何从node.js“登录”?

这是我的同事给我的xml代码段。显然它有助于身份验证。但我不知道我想用它做什么。

<binding name="NotificationManager" >
    <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm" proxyCredentialType="None" realm=""/>
             <message clientCredentialType="UserName" algorithmSuite="Default"/>
    </security>
</binding>

这是我尝试过的:

方法1:

var soap = require('soap');

soap.createClient(soapURL, function(err, client) {
    console.log('client created');
    if (err)
      {
          console.log('ERR: -> ');
          console.log(err);
          return false;
      }
    client.setSecurity(new soap.BasicAuthSecurity(username,password));
    console.log('successfully authenticated');
    });
});

方法1问题 我会得到一个错误。错误页面是一个html文档,其中显示应用程序中的服务器错误。服务器版本Iternet Information Services 7.5。由于身份验证标头无效,您无权查看此页面。

如果我在'client.setSecurity()'方法之后输入错误日志,那么程序将崩溃,并显示错误,指出无法定义.setSecurity()。

方法2:

我看到xml提到了ntlm,所以我想我会尝试一下。

var soap = require('soap');
var httpntlm = require('httpntlm');
var fs = require('fs');

httpntlm.get({
  url: soapURL,
  password: password,
  username: username
}, function(err, wsdl) {

    console.log('successfully authenticated');
    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);
    });

  })

});

方法2问题

对于此方法,我将成功验证并将WSDL下载到文件系统中。但是,我会得到关于“您无权查看此页面...”的相同错误。除了这次,它是我已缓存导入的文件之一。

在这种情况下,与这种类型的SOAP Web服务进行交互的正确方法是什么?

0 个答案:

没有答案
相关问题