我到现在才用肥皂。我正在使用node soap库(https://github.com/vpulim/node-soap)。
我想和soap服务器通信。为了维护会话,服务器向我发送set cookie response header:'ASP.NET_SessionID=55....hrc; path/; HttpOnly'和登录方法response。我想在注销方法请求中发送此cookie。
我试着:
client.addHttpHeader('cookie','asp.net_sessionid=55….hrc');
但随后:

client.LogoutAsync({})
    .then(result => {console.log(result);})
    .catch(error => {console.log(error);});

我得到一个错误:
events.js:183 throw er; //Unhandled 'error' event

这是怎么回事,我怎么能寄回饼干头?
p.s.wihtout cookie返回meLogout: false时它按预期工作,这意味着错误发生是因为它无法识别会话(我想)。

最佳答案

我也遇到过同样的问题,发现可以通过标题来解决:

soap.createClientAsync(this.url, this.options).then(client => {
  client.addHttpHeader('Cookie', 'ASP.NET_SessionId=' + this.sessionId)
  client.GetIdentity((err, results) => {
    if (err) reject(err)
    resolve(results)
  })
})

07-24 09:48
查看更多