我有一些示例代码如下所示:
var soap = require('soap');
var url = "http://www.example.com?wsdl";
var soapHeader = "<AuthHeader>...</AuthHeader>";
soap.createClient(url, function(err, client){
client.addSoapHeader(soapHeader);
var args = {
'arg1': 1
}
};
client.SomeMethod(args, function(err, result){
if(err){
throw err;
}
console.log(JSON.stringify(result));
});
});
问题是请求因为错误的标题或我传递的参数而失败。如果我能看到整个请求体,那么调试会容易得多。怎么做的?
答案 0 :(得分:0)
不确定这是否仍然与您相关,但是这里有:
var soap = require('soap');
var url = "http://www.example.com?wsdl";
var soapHeader = "<AuthHeader>...</AuthHeader>";
soap.createClient(url, function(err, client){
client.addSoapHeader(soapHeader);
var args = {
'arg1': 1
}
};
client.SomeMethod(args, function(err, result){
if(err){
throw err;
}
console.log('last request: ', client.lastRequest);
console.log(JSON.stringify(result));
});
});
带有“ lastRequest”的额外console.log语句将显示正在发送的XML请求,该请求可用于调试。希望这会有所帮助。