我正在尝试使用以下脚本发出HTTPS POST SOAP 请求:
var http = require('http');
function Authenticate() {
// Build the post string from an object
var post_data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:typ=\"http://company.com/mse/types\"><soapenv:Header/><soapenv:Body><typ:Login><typ:Credential userName=\"username\" password=\"password\"/></typ:Login></soapenv:Body></soapenv:Envelope>";
// An object of options to indicate where to post to
var post_options = {
port: 443,
host: 'https://132.33.223.33', //MSE12
path: '/aaa/',
method: 'POST',
headers: {
'Content-Type': 'text/xml;charset=UTF-8',
'SOAPAction': '\"Login\"',
'Accept-Encoding': 'gzip,deflate',
'Host':'173.37.206.33',
'Connection':'Keep-Alive',
'User-Agent':'Apache-HttpClient/4.1.1 (java 1.5)'
}
};
// Set up the request
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
post_req.on('error', function (err) {
//handle error here
console.log(err);
});
// post the data
post_req.write(post_data);
post_req.end();
}
Authenticate();
IPAddress 和有效负载已更改。我知道请求成功,因为标头、请求正文和请求 url 在 F 中正常工作
执行时,我一直遇到此错误:
{ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
在发出这个 HTTPS 请求时,谁能看到我在这个脚本中做错了什么?我尝试搜索此错误消息,它一直指向有关主机问题的论坛线程。
任何指针将不胜感激。