急急急!!!通过js 用ajax调用web service代码
刚接触web service,现在有一个测试例想用js编写ajax post方式调用服务,一直调用不通,求代码或更正!!!
web service 地址:http://211.155.235.53:81/AJAXWebService/Service1.asmx
求代码!!!
我编写的代码如下:
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST","http://211.155.235.53:81/AJAXWebService/Service1.asmx",true);
var tt;
xmlhttp.setRequestHeader('Content-Type','text/xml');
xmlhttp.setRequestHeader('charset','utf-8');
xmlhttp.setRequestHeader('Content-Length','250');
xmlhttp.setRequestHeader('SOAPAction','http://tempuri.org/CalculateTmp');
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=tt+'<soap:Body>';
tt=tt+'<CalculateTmp xmlns="http://tempuri.org/">';
tt=tt+'<ss>15</ss>';
tt=tt+'</CalculateTmp>';
tt=tt+'</soap:Body>';
tt=tt+'</soap:Envelope>';
xmlhttp.send(tt);