3
我在asp.net中創建了一個web服務,並嘗試從域內本地計算機的html文件訪問它。Web服務器設置Access-Control-Allow-Headers
我收到此錯誤
的XMLHttpRequest無法加載http://10.112.37.31/amanopoc/Service1.asmx。 訪問控制允許標題不允許請求標頭字段SOAPAction。
try {
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
catch (e)
{
xmlhttp = false;
}
if(xmlhttp)
{
xmlhttp.open ('POST', postUrl, true);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4) {
if (xmlhttp.status !=404)
{
//alert(xmlhttp.responseText);
//alert("TEST 1");
var xmlDoc = xmlhttp.responseText;
if(xmlDoc)
{
var x=xmlhttp.responseXML.selectSingleNode("//ObjectToXmlResult").text;
//var y=x.getElementByTagName("HelloWorldResult");
alert(x);
}
else
{
alert("xmlDoc is null");
}
}
else
{
alert("xmlhttp.status =" + xmlhttp.status);
}
}
};
xmlhttp.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
xmlhttp.setRequestHeader("SOAPAction", soapActionUrl);
xmlhttp.setRequestHeader("Content-Length", soapHeader.length);
xmlhttp.send(soapHeader);
}
可以在任何
你能鏈接到一些相關的文檔嗎? – talljosh 2012-05-28 07:21:50
這裏是關於在IIS中設置自定義標題的technet文章http://technet.microsoft.com/en-us/library/cc753133(v=ws.10).aspx – rob 2012-05-29 10:15:36