我打算使用Ajax向soap web服务发送跨域请求 网络服务的网址是:http://example1.asmx?op=GetVOD
我的代码:
var url = 'http://example1.asmx?op=GetVOD';
var xhr = new XMLHttpRequest();
var strRequest = "<?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>" +
"<getVODTypeList xmlns='http://tv21.com/' />" +
"</soap:Body>" +
"</soap:Envelope>"
xhr.open('POST', url, true);
xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xhr.setRequestHeader("SOAPAction", "http://tv21.com/getVOD");
xhr.send(strRequest);
在IIS 7服务器端,我已经将这些行添加到web.config文件
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
当我在Chrome上运行客户端代码时,我遇到405错误:
http://example1.asmx?op=GetVOD 405 (Method Not Allowed)
http://example1.asmx?op=GetVOD Invalid HTTP status code 405
有谁知道如何解决这个问题?
提前感谢