87,915
社区成员
发帖
与我相关
我的任务
分享
<script language=javascript>
var strUrl="http://www.ayandy.com/Service.asmx";
var strSoapRequestXml='<?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> <getWeatherbyCityName xmlns="http://tempuri.org/"> <theCityName>昆明</theCityName> <theDayFlag>Today</theDayFlag> </getWeatherbyCityName> </soap:Body> </soap:Envelope>';
function test(strUrl,strSoapRequestXml){
try
{
var objXMLHttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");
objXMLHttp.open("Post",strUrl, true); //修改了这里第三个参数,另外第一个用post 还是get
objXMLHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
objXMLHttp.setRequestHeader("SOAPAction", "http://tempuri.org/getWeatherbyCityName");
objXMLHttp.send(strSoapRequestXml);
objXMLHttp.onreadystatechange = function () {//添加了状态改变事件
if (objXMLHttp.readyState == 4)
{
if(objXMLHttp.status==200)
{
alert(objXMLHttp.responseText);
}else
{
alert(objXMLHttp.statusText);
}
}
}//onreadystatechange
objXMLHttp.send(strSoapRequestXml); //send位置对吗?
}//try
catch(e){alert(e.description)}
test(strUrl,strSoapRequestXml);
}
</script>