gpt4 book ai didi

node.js - NodeJS - 如何获取 SOAP 网络服务响应的 HTTP header

转载 作者:可可西里 更新时间:2023-11-01 17:06:34 27 4
gpt4 key购买 nike

当使用“soap”包在 NodeJS 中使用 SOAP 网络服务时。像这样:

var soap = require('soap');
var url = 'http://example.com/wsdl?wsdl';
var args = {name: 'value'};
clientsoap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result, raw, soapHeader) {
console.log(result);
});
});

如何获取对 MyFunction 的响应的 HTTP header ?具体来说,我想要 HTTP header 中的 Cookie 参数。

这是 Node/Express 可以做的事情吗?或者我需要另一个包来实现这个目标吗?

提前致谢。

最佳答案

NodeJS soap 模块在调用方法时存储针对客户端的最后响应 header ,因此只需在回调中访问它:

var soap = require('soap');
var url = 'http://somewhere.com?wsdl';
var args = {name: 'value'};
soap.createClient(url, function(err, client) {
client.myFunction(args, function(err, result) {
console.log(client.lastResponseHeaders);
});
});

关于node.js - NodeJS - 如何获取 SOAP 网络服务响应的 HTTP header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38709527/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com