<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<script language="javascript">
//test function with post method
function RequestByPost(value)
{
var data;
data = '<?xml version="1.0" encoding="utf-8"?>';
data = data + '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">';
data = data + '<soapenv:Body>';
data = data + '<ns1:getUser xmlns:ns1="http://ss/">';
data = data + '<Name>'+"ffff"+'</Name>';
data = data + '</ns1:getUser>';
data = data + '</soapenv:Body>';
data = data + '</soapenv:Envelope>';
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var URL="http://localhost:8080/myPj/SayHelloTo?wsdl";
xmlhttp.Open("POST",URL, false);
xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=UTF-8");
xmlhttp.SetRequestHeader ("SOAPAction","http://ss/SayHelloTo");
alert(data);
xmlhttp.Send(data);
alert( xmlhttp.responseText);
document.getElementById('mm').value=xmlhttp.responseText;
}
</script>
<title>
Call webservice with javascript and xmlhttp.
</title>
<body>
<div id="mm">
<input type="button" value="CallWebserviceByGet" onClick="RequestByGet(null)">
<input type="button" value="CallWebserviceByPost" onClick="RequestByPost('Zach')">
<input id="mm" type="text"/>
</body>
</html>
大盘预测
国富论
posted on 2007-07-17 16:18
华梦行 阅读(156)
评论(0) 编辑 收藏