在流星客户端,我需要向SOAP API发送请求。如您所见,发送请求的函数:
const xmlHttp = new XMLHttpRequest();
xmlHttp.open(
'POST',
'http://www.holidaywebservice.com//HolidayService_v2/HolidayService2.asmx?wsdl',
true
);
const sr = `<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hs="http://www.holidaywebservice.com/HolidayService_v2/">
<soapenv:Body>
<hs:GetHolidaysAvailable>
<hs:countryCode>UnitedStates</hs:countryCode>
</hs:GetHolidaysAvailable>
</soapenv:Body>
</soapenv:Envelope>`;
xmlHttp.onreadystatechange = () => {
if (xmlHttp.readyState === 4) {
if (xmlHttp.status === 200) {
//...
}
}
};
xmlHttp.setRequestHeader(
'Access-Control-Allow-Headers',
'X-Requested-With, Content-Type, Authorization'
);
xmlHttp.setRequestHeader(
'Access-Control-Allow-Methods',
'GET,PUT,POST,DELETE,OPTIONS'
);
xmlHttp.setRequestHeader('Access-Control-Allow-Origin', '*');
xmlHttp.send(sr);
}
我阅读了类似的问题,但发现的解决方案不起作用。
我该如何解决?