📄 employeeserviceclient.aspx
字号:
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>
IE Web Service Behavior for asynchronously invoking the Web Service
</title>
<SCRIPT LANGUAGE="JScript">
//Declare a module level variable to capture the event id
var iCallID ;
function GetEmployeeDetails()
{
//Call the GetEmployeeDetails method on the svcEmployee web service
iCallID = service.svcEmployee.callService
(DisplayResults,"GetEmpDetailsByEmpID",txtEmployeeID.value);
}
function DisplayResults(result)
{
var strXML,objXMLNode,objXMLDoc,objEmployee,strHTML;
//Check if the event id is the same
if (iCallID != result.id)
return;
if(result.error)
{
//Pull the error information from the errorDetail property
var faultCode = result.errorDetail.code;
var faultString = result.errorDetail.string;
alert("ERROR: Code = " + faultCode + ", Fault String=" + faultString);
}
else
{
//Get the resultant value into a local variable
objXMLNode = result.value;
objXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
//Load the returned XML string into XMLDOM Object
objXMLDoc.loadXML(objXMLNode.xml);
//Get reference to the Employees Node
objEmployee = objXMLDoc.selectSingleNode ("GetEmpDetailsByEmpIDResult").
selectSingleNode("EmployeesRoot").selectSingleNode("Employees");
//Check if a valid employee reference is returned from the server
strHTML = "<font color='#0000FF'>";
if (objEmployee != null)
{
strHTML += "<br><br>Employee ID :<b>" +
objEmployee.selectSingleNode("EmployeeID").text + "</b><br><br>";
strHTML += "Title :<b>" + objEmployee.selectSingleNode("Title").text +
"</b><br><br>";
strHTML += "Birth Date :<b>" +
objEmployee.selectSingleNode("BirthDate").text + "</b><br><br>";
strHTML += "Marital Status :<b>" +
objEmployee.selectSingleNode("MaritalStatus").text + "</b><br><br>";
}
else
{
strHTML += "<br><br><b>Employee not found</b>";
}
strHTML += "</font>"
//Assign the dynamically generated HTML into the div tag
divContents.innerHTML = strHTML;
}
}
function init()
{
//Create an instance of the web service and call it svcEmployee
//service.useService("http://localhost/MyProjects/Wrox/Chapter13/WebService/EmployeeService.asmx?WSDL", "svcEmployee");
service.useService("http://localhost/MyProjects/Wrox/Review/Chapter13/EmployeeService.asmx?WSDL","svcEmployee");
}
</script>
</head>
<body onload="init()">
<div id="service" style="BEHAVIOR: url(webservice.htc)"></div>
<H1 align="center">Employee Details</H1>
<br><br>
<P align="left"><b>Enter the Employee ID:</b>
<INPUT id="txtEmployeeID" name="txtEmployeeID"
style="LEFT: 149px; TOP: 72px">
<INPUT id="btnAdd" type="button" value="Get Employee Details"
name="btnGetEmployee" onclick="return GetEmployeeDetails()">
</P>
<P></P>
<div id="divContents">
</div>
<P></P>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -