ATLAS----调用WebService
程序出自http://atlas.asp.net/docs/Walkthroughs/GetStarted/Basic.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<atlas:ScriptManager runat="server" ID="scriptManager">
<services>
<atlas:servicereference path="~/HelloWorldService.asmx" />
</services>
</atlas:ScriptManager>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }
.text { font: 8pt Trebuchet MS }
</style>
</head>
<body>
<form runat="server">
<div>
Search for
<input id="SearchKey" type="text" />
<input id="SearchButton" type="button"
value="Search"
onclick="DoSearch()" />
</div>
</form>
<hr style="width: 300px" />
<div>
<span id="Results"></span>
</div>
<script type="text/javascript">
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}
function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}
</script>
</body>
</html>
ScriptManager控件内的 <services>标记包含页面所调用的webservice的文件名称。如下
<services>
<atlas:servicereference path="~/HelloWorldService.asmx" />
</services>
然后通过javascript脚本调用这个web服务,
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");//得到id名位SearchKey的html元素
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value, OnRequestComplete);
//DoSearch方法调用远程的web服务的HelloWorld方法,将SerchElem.Value指HelloWorld的参数,OnRequestComplete指本地的回调函数。首先调用HelloWorld方法,挥发后将返回值作为参数传递给OnRequestComplete方法...
HelloWorld的函数定义为
[WebMethod]
string HelloWorld(string str)
{
/////.....code herer
return "sfsdfsdfdsf";
}
}
function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<atlas:ScriptManager runat="server" ID="scriptManager">
<services>
<atlas:servicereference path="~/HelloWorldService.asmx" />
</services>
</atlas:ScriptManager>
<style type="text/css">
body { font: 11pt Trebuchet MS;
font-color: #000000;
padding-top: 72px;
text-align: center }
.text { font: 8pt Trebuchet MS }
</style>
</head>
<body>
<form runat="server">
<div>
Search for
<input id="SearchKey" type="text" />
<input id="SearchButton" type="button"
value="Search"
onclick="DoSearch()" />
</div>
</form>
<hr style="width: 300px" />
<div>
<span id="Results"></span>
</div>
<script type="text/javascript">
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}
function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}
</script>
</body>
</html>
ScriptManager控件内的 <services>标记包含页面所调用的webservice的文件名称。如下
<services>
<atlas:servicereference path="~/HelloWorldService.asmx" />
</services>
然后通过javascript脚本调用这个web服务,
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");//得到id名位SearchKey的html元素
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value, OnRequestComplete);
//DoSearch方法调用远程的web服务的HelloWorld方法,将SerchElem.Value指HelloWorld的参数,OnRequestComplete指本地的回调函数。首先调用HelloWorld方法,挥发后将返回值作为参数传递给OnRequestComplete方法...
HelloWorld的函数定义为
[WebMethod]
string HelloWorld(string str)
{
/////.....code herer
return "sfsdfsdfdsf";
}
}
function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}