<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>htmlWebpackPlugin.options.title</title>
</head>
<body>
<input type="button" value="viewResult" onclick="invokeServerFunction()" />
<br/>
<br/>
Web服务所返回的结果为:<span id="result"></span>
<script type="text/javascript">
function invokeServerFunction(){
var xmlHttp;
try{
xmlHttp = new XMLHttpRequest();
}catch(e){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(e){
alert("很遗憾, 您的浏览器不支持AJAX, 请使用其它浏览器, 如Firefox、Safari、Opera8.0+");
return false;
}
}
}
xmlHttp.onreadystatechange = function(){
if(4 == xmlHttp.readyState){
alert(xmlHttp.status);
if(200 == xmlHttp.status){
document.getElementById("result").innerHTML = xmlHttp.responseText;
}
}
}
var data = ''
+ '<?xml version="1.0" encoding="utf-16"?>'
+ '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'
+ '<soap:Body>'
+ '<allDsjk xmlns="http://server.wei.com">'
+ '<xml>0000</xml>'
+ '</allDsjk>'
+ '</soap:Body>'
+ '</soap:Envelope>'
var url = "";
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader ("Content-Type", "text/xml; charset=UTF-8");
xmlHttp.setRequestHeader ("SOAPAction", "");
xmlHttp.send(data);
}
</script>
</body>
</html>