深入Atlas系列:Web Sevices Access in Atlas(7) - RTM中的客户端支持


本片文章部分内容会基于我之前的文章:《深入Atlas系列:Web Sevices Access in Atlas(1) - 客户端支持》。

  在RTM版本中,客户端访问Web Services的方法发生了改变。在《深入Atlas系列:Web Sevices Access in Atlas(1) - 客户端支持》和它对应的示例《深入Atlas系列:Web Sevices Access in Atlas示例(1) - 特别的访问方式》中我们知道了从客户端访问Web Services的基础类库以及方法。它们是:

  Sys.Net.ServiceMethod类。

  Sys.Net.ServiceMethod.invoke方法的两个重载。

  在RTM版本中,客户端访问Web Services的基础类库发生了一些改变,并直接影响到了它们的使用方式。对于自己写ASP.NET AJAX组件(例如ExtenderControl)的朋友们来说,了解这部分改变是非常重要的。

  一、Sys.Net.ServiceMethod -> Sys.Net._WebMethod

  在CTP版本中,Sys.Net.ServiceMethod是客户端访问Web Services的基础类,它继承于Sys.Net.WebMethod。同样继承于Sys.Net.WebMethod的还有Sys.Net.PageMethod,它用于访问PageMethod,这个类在RTM版本中被取消了。现在,客户端用于访问Web Service的类已经变成了Sys.Net._WebMethod(从命名上来看,很明显它不希望用户直接使用这个类),而且在使用上也有了很大的变化。

  我们先来回忆一下CTP中Sys.Net.ServiceMethod的使用方式。如下:

var serviceMethod = new Sys.Net.ServiceMethod(url, methodName, appUrl);
  
serviceMethod.invoke(
  parameters,
  onMethodComplete,
  onMethodTimeout,
  onMethodError,
  onMethodAborted,
  userContext,
  timeoutInterval,
  priority);
  而在RTM版本中,Sys.Net._WebMethod的使用方式如下:
var method = new Sys.Net._WebMethod(proxy, methodName, fullName, useGet);
method._execute(params, onSuccess, onFailure, userContext);
  CTP版本中Sys.Net.ServiceMethod中的invoke方法还有一个重载,在RTM版本中就不存在了。在Sys.Net._WebMethod的构造函数中,出现了一个“proxy”参数,这是什么呢?我们来看一下method._execute方法的代码。如下:

function Sys$Net 深入Atlas系列:Web Sevices Access in Atlas(7) - RTM中的客户端支持 - 站长学院

深入Atlas系列:Web Sevices Access in Atlas(7) - RTM中的客户端支持

2008-11-15 0:01:00查看学习心得
{GetProperty(Content)} 本文作者:
« 
» 

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3