当前位置: 代码迷 >> JavaScript >> 用js编撰测试axis页面
  详细解决方案

用js编撰测试axis页面

热度:129   发布时间:2012-11-23 00:03:43.0
用js编写测试axis页面

<html>
<head>
<title>测试短信专家系统的WebService服务</title>
<STYLE type="text/css">
p,div,a {
?marign: 0px;
?padding: 0px;
?font-size: 12px;
?font-family: "Tahoma", "Arial", "";
}

table,td {
?marign: 0px;
?padding: 0px;
?font-size: 12px;
?font-family: "Tahoma", "Arial", "";
?line-height: 150%;
?white-space: normal;
?word-wrap: break-word;
?word-break: break-all;
?border-style: dotted;
?border-width: 1px;
}

input,option,select {
?marign: 0px;
?padding: 0px;
?font-size: 12px;
?font-family: "Tahoma", "Arial", "";
?border-style: solid;
?border-width: 1px;
?border-color: #ccc;
}

.divininoShow {
?display: none;
}
.fontRed {
?color: red;
}
</style>

<script language="javascript">

function HTTPRequest()
{
 var xmlhttp=null;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (_e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (_E) { }
 }
 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  try {
   xmlhttp = new XMLHttpRequest();
  } catch (e) {
   xmlhttp = false;
  }
? }
 return xmlhttp;
}

1 楼 aiyalhw 2009-12-24  

</head>
<body>
<h5 align="center">测试短信专家系统的WebService服务</h5>

<p>WebService服务地址:<input type="text" id="epr"
value="http://10.71.173.55:8089/services/SmsInterfaceService"
size="80" /> <font class="fontRed">*</font></p>

<input type="button" onclick="displayDiv('smcDetailQuery')" value=" 测试明细查询" />

<hr width="100%" align="left" />


<div id="smcDetailQuery" class="divininoShow">

<table>
<tr>
<td>用户名</td>
<td><input type="text" id="user" value="webservice" /></td>
<td></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" id="userPwd" value="ZuGk3JPiITU9rpUA7RlU8OqLFPc=" /> </td>
<td>密码需加密后发送</td>
</tr>
<tr>
<td>主叫号码</td>
<td><input type="text" id="orgNo" value="" /> </td>
<td></td>
</tr>
<tr>
<td>被叫号码</td>
<td><input type="text" id="destNo" value="8613500000009" /> </td>
</tr>
<tr>
<td>开始时间</td>
<td><input type="text" id="startTime" value="20091111000000" /></td>
<td>&nbsp;时间格式:yyyyMMddHHmmss</td>
</tr>
<tr>
<td>结束时间</td>
<td><input type="text" id="endTime" value="20091111000500" />   </td>
<td>&nbsp;时间格式:yyyyMMddHHmmss</td>
</tr>
<tr>
<td><input type="button"
onclick="javascript:Http_RequestSmcDetailQuery();" value=" send " /></td>
<td>&nbsp;</td>
</tr>
</table>

</div>

<table border="0" width="100%">
<tr>
<td id="tdresult"></td>
</tr>
</table>
</body>
</html>
2 楼 aiyalhw 2009-12-24  

function Http_RequestSmcDetailQuery()
{
//alert($("user").value+$("userPwd").value+$("orgNo").value+$("destNo").value+$("startTime").value+$("endTime").value);
//alert(startTime.value+endTime.value);
  soaprequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + String.fromCharCode(10);
  soaprequest += "<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/\">" + String.fromCharCode(10);
  soaprequest += "<soap:Body>" + String.fromCharCode(10);
  soaprequest += "<SmcDetailQuery xmlns=\"http://sms.huawei.com/smsinterfaceservice\">" + String.fromCharCode(10);
  soaprequest += "<SmcDetailQueryRequest>" + String.fromCharCode(10);
  soaprequest += "<RequestMessage>" + String.fromCharCode(10);
  soaprequest += "<user>" + $("user").value + "</user>" + String.fromCharCode(10);
  soaprequest += "<userPwd>" + $("userPwd").value + "</userPwd>" + String.fromCharCode(10);
  soaprequest += "<orgNo>" + $("orgNo").value + "</orgNo>" + String.fromCharCode(10);
  soaprequest += "<destNo>" + $("destNo").value + "</destNo>" + String.fromCharCode(10);
  soaprequest += "<startTime>" + startTime.value + "</startTime>" + String.fromCharCode(10);
  soaprequest += "<endTime>" + endTime.value + "</endTime>" + String.fromCharCode(10);
  soaprequest += "</RequestMessage>" + String.fromCharCode(10);
  soaprequest += "</SmcDetailQueryRequest>" + String.fromCharCode(10);
  soaprequest += "</SmcDetailQuery>" + String.fromCharCode(10);
  soaprequest += "</soap:Body>" + String.fromCharCode(10);
  soaprequest += "</soap:Envelope>" + String.fromCharCode(10);
 
 
 var http = new HTTPRequest();
 http.open("POST", $("epr").value, true);
  http.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
  //http.setRequestHeader("Host","http://10.71.172.142:8080/"); 
  http.setRequestHeader("Content-Length",soaprequest.length);
  http.setRequestHeader("SOAPAction", "http://sms.huawei.com/smsinterface");
 http.onreadystatechange = function (){ handleHttpResponse(http)};
 http.send(soaprequest);

}

function handleHttpResponse(http)
{
if (http.readyState == 4)
{
var result = http.responseText;
//alert(result);
//var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//xmlDoc.async = false;
//xmlDoc.loadXML(result);
//tdresult.innerText = result;
tdresult.innerText = result;
}
else
{
tdresult.innerHTML = "loading..."//"<img src='ico_loading2.gif'></img>";
}
}

var myArray = new Array("smcDetailQuery");

function displayDiv(str1)
{
var obj1 = $(str1);

if (obj1.style.display == 'block')
{
obj1.style.display = 'none';
}
else
{
obj1.style.display = 'block';
}

for (key in myArray)
{
if (myArray[key] != str1)
{
$(myArray[key]).style.display = 'none';
}
}
//document.getElementById("tdresult").innerHTML = "";
}
function $(str)
{
return document.getElementById(str);
}
</script>