Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > .NET > VB.NET > Atlas笔记1:介绍和调用WebService的方法
【标  题】:Atlas笔记1:介绍和调用WebService的方法
【关键字】:Atlas,WebService
【来  源】:http://dlwang2002.cnblogs.com/archive/2006/02/07/326747.html

Atlas笔记1:介绍和调用WebService的方法

Your Ad Here Atlas是运行在Asp.net2.0环境下的一个项目,微软的AJAX项目。
Atlas主页http://www.asp.net/default.aspx?tabindex=7&tabid=47

AJAX (Asynchronous JavaScript and XML),结合上.net2.0的功能效果自然非同凡响。网页的也不调用可以避免无谓的网页周期,使浏览速度大大加快,也可以减轻服务器的负荷;用户体验上,可以创建rich UI,制作富有表现力的网页不再那么麻烦。

安装atlas比较简单,只要有asp。net2.0,然后下在一个项目模版文件安装就可以了。

按照Atlas Quickstart Tutorials 的步骤,先开始第一个测试:异步调用WebService。

在atlas项目里面:

1:先创建一个简单的WebService
public class WebServiceT1 : System.Web.Services.WebService
{

    
public WebServiceT1()
    

    }


    [WebMethod]
    
public string TestMethod(string msg)
    
{
        System.Threading.Thread.Sleep(
1000 * 60 * 21);
        
return "the webService got it:"+msg;
    }


}

 

2:创建一个aspx页面
      首先在页面上添加一个atlas引用:
      注意里面要引用上WebService的地址。幸好2.0里面的代码自动完成功能作的比较多,不噢能够自己写太多代码,输入几个字母就有提示了。

<atlas:ScriptManager ID="ScriptManager1" runat="server" EnableScriptComponents='false'>
                
<Services>
                    
<atlas:ServiceReference Path='WebServiceT1.asmx' />
                
</Services>
            
</atlas:ScriptManager>

然后再页面上加上两个html控件:一个按钮一个文本框。双击文本框,他会自动给创建一个client端的事件,自动创建一个js函数

                
<input id="Button1" type="button" value="click me and will invoke the webservice" onclick="return Button1_onclick()" />
                
<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>

js函数

function Button1_onclick()
 
{
   WebServiceT1.TestMethod(document.getElementById(
'TextBox1').value,OnComplet,OnTimeOut);//异步调用,传递两个事件的回调函数:完成之后;超时
   
   
return true;
}

function OnComplet(result)
{
//得到返回值.这个result是个objext类型的,可以传递一个类的实例过去,比如DataTable。
  window.alert(result);
}

function OnTimeOut(result)
{
//居然也有返回值,不知道是什么
  window.alert('time out. got nothing from the server');
  window.alert(result);
}

运行测试之就可以了。

几个问题:
1:传递的类型可以是复杂类型,除了string之类也可以一个类的实例。返回值也是。
      可以这样使用:result.Name=xx。详细的介绍会在以后的“atlas数据邦定”中有。
2:好像WebService的方法必须得有一个参数。
3:也可以没有OnTimeOut处理。

 

 

 

Regex 101 Exercise I7 - Make sure all characters inside are uppercase:【上一篇】
.net下paypal的电子支付方式编程(1):【下一篇】
【相关文章】
  • 学习Atlas是发现的几个小问题
  • webservice Quiz(Wsdl &Soap)
  • Atlas Table Layout Template
  • WebService Behavior 学习心得
  • ASP.NET ‘Atlas’ Technology Preview October 2005 release
  • "401: Access Denied" when you call webservice in your webpart.
  • Ajax&Atlas技术团队成立,请大家踊跃参加!
  • Ajax&Atlas技术团队下一步活动讨论,请团队成员进来给点意见!
  • Ajax&Atlas技术团队[公告]:请大家清理自己发布在团队页面上的post!
  • 究竟谁的WebService效率高?
  • 【随机文章】
  • Linux 指令篇:编码压缩打包--uudecode
  • 非线编网络IP存储解决方案
  • JAVA认证问答
  • R6中表格隐藏的问题
  • DisplayTagPro 1.1 加入了一个新的属性scope
  • 【转贴】人生算法
  • 解决 FireFox 下[使用event很麻烦] 的问题.
  • 示例介绍防火墙与SOHO的相关联系
  • 佛教纪念日
  • JavaScript就这么回事4:表单
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.