【发布时间】:2017-11-24 01:06:55
【问题描述】:
我正在尝试使用 npm soap 包创建一系列到远程服务器的端点,我可以通过 angular 4 与之交互。我已经阅读了文档,但我仍然不清楚它的用法。下面是 WSDL。如何创建可用于与以下端点交互的客户端?这是 WSDL。
http://208.180.122.191:8081/niku/wsdl/Query/ts_pending_approvals?tenantId=clarity
我的期望是我应该得到以下回复:
var soap = require('soap');
var url = 'http://208.180.122.191:8081/niku/wsdl/Query/ts_pending_approvals?tenantId=clarity';
var args = {Username: "jdoe", Password: "*******"};
soap.createClient(url, function(err, client) {
client.Login(args, function(err, result) {
console.log(result);
});
});
当我调用 console.log(client.describe()) 时,我得到以下信息:
{ ts_pending_approvalsQueryService:
{ ts_pending_approvalsQueryService:
{ Query: [Object],
Login: [Object],
WrappedLogin: [Object],
Logout: [Object] } } }
但是,当我调用 login 并传递用户名和密码时,我得到了未定义。使用 SoapUI,我能够使用以下命令成功完成请求。我的问题是如何在 node.js 中模拟这个。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://www.niku.com/xog/Query">
<soapenv:Header/>
<soapenv:Body>
<quer:Login>
<quer:Username>jdoe</quer:Username>
<quer:Password>******</quer:Password>
</quer:Login>
</soapenv:Body>
</soapenv:Envelope>
【问题讨论】: