我发现了一篇类似的帖子here,但我仍然无法找到解决方案以解决我面临的问题。
这是我的肥皂请求的jquery片段。
<script type="text/javascript">
var invocation;
$(document).ready(function () {
invocation = new XMLHttpRequest();
var webserUrl = "https://sc.quikstor.com/eComm3ServiceSS/QuikStorWebServiceSS.asmx/SmartPhone_Download_TenantInformation";
var soapRequest = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
'<soap:Body>' +
' <SmartPhone_Download_TenantInformation xmlns="http://tempuri.org/">' +
'<csUser>someuser</csUser>' +
'<csPassword>userpassword</csPassword>' +
'<csSiteName>someString</csSiteName>' +
'<sSearchBy>someString</sSearchBy>' +
'</SmartPhone_Download_TenantInformation>' +
'</soap:Body>' +
'</soap:Envelope>';
if (invocation) {
invocation.open('POST', webserUrl, true);
invocation.setRequestHeader('X-PINGOTHER', 'GetTenant');
invocation.setRequestHeader('Content-Type', 'text/xml');
invocation.onreadystatechange = function (data) { handleStateChange(data) };
invocation.send(soapRequest);
}
});
function handleStateChange(data) {
switch (invocation.readyState) {
case 0: // UNINITIALIZED
case 1: // LOADING
case 2: // LOADED
case 3: // INTERACTIVE
break;
case 4: // COMPLETED
//alert(data);
break;
default: alert("error");
}
}
</script>
它在控制台上出现以下错误:
XMLHttpRequest cannot load https://sc.quikstor.com/eComm3ServiceSS/QuikStorWebServiceSS.asmx/?op=SmartPhone_Download_TenantInformation. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:50099' is therefore not allowed access.
我在soapRequest中定义了标题,但它仍然给了我这个错误。我无法找到解决方案。有什么建议??