<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312"/>
<title>test</title>
</head>
<body>
<input value="send" type="button" style="width: 61px" id="Button1" name="Button1" onclick="return Button1_onclick()" />
<div id="result"></div>
<script language="javascript" type="text/javascript">
// <!CDATA[
var xmlhttp
var r=document.getElementById("result");
function Button1_onclick() {
SoapProtocal();
}
function HttpPost()
{
xmlhttp=getHTTPObject();
xmlhttp.open("post","http://fhs.6617.com/getweather.asmx/GetCityWeather",true);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.onreadystatechange=showresult;
xmlhttp.send("city=北京");
}
function SoapProtocal()
{
xmlhttp=getHTTPObject();
xmlhttp.open("post","http://fhs.6617.com/getweather.asmx",true);
xmlhttp.setRequestHeader('Content-Type','text/xml; charset=utf-8');
xmlhttp.setRequestHeader('SOAPAction','http://fhs.6617.com/WeatherService/GetCityWeather');
xmlhttp.onreadystatechange=showresult;
var tt;
tt='<?xml version="1.0" encoding="utf-8"?>';
tt+='<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/">';
tt+='<soap:Body>';
tt+="<GetCityWeather xmlns=/"http://fhs.6617.com/WeatherService/">"
tt+="<city>北京</city>"
tt+="</GetCityWeather>";
tt+='</soap:Body>';
tt+='</soap:Envelope>';
xmlhttp.send(tt);
}
function showresult(){
if (xmlhttp.readyState == 4)
{
if (xmlhttp.status == 200)
{
var result = xmlhttp.responseText;
r.innerHTML =r.innerHTML+ result +"<br/>" ;
}
else
r.innerHTML =r.innerHTML+xmlhttp.status +"<br/>" ;
}
}
function getHTTPObject(){
var xmlhttp = false;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType('text/xml');
}
}
else{
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlhttp = false;
}
}
}
return xmlhttp;
}
// ]]>
</script>
</body>
</html>