客户端访问Web Service方法的一个细节

[复制链接]
查看11 | 回复2 | 2007-6-22 01:03:37 | 显示全部楼层 |阅读模式
之前遇到一个要求,需要能够取消一个正在进行中的Web Service。这也是我第一次遇到这个功能,不过不难,我想。既然ASP.NETAJAX的客户端与服务器端通信完全通过Microsoft AJAX Library的异步通信层进行,那么我们只要得到正在请求WebService的Sys.Net.WebRequest对象,调用其abort方法就可以了。但是究竟应该如何得到这个对象呢?于是我粗略地阅读了一下代码。   首先假设有如下的Web Service方法定义(DemoService.asmx):
[ScriptService]
public class DemoService: System.Web.Services.WebService
{
[WebMethod]
public string DemoMethod()
{
return "Hello World";
}
}
  访问DemoService.asmx/jsdebug(或者将其使用ScriptManager引用到页面中之后)就能够得到如下的代理(片断、经过排版)类。
var DemoService = function()
{
DemoService.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
DemoService.prototype =
{
DemoMethodunction(succeededCallback, failedCallback, userContext)
{
return this._invoke(

DemoService.get_path(),

'DemoMethod',

false,

{},

succeededCallback,

failedCallback,

userContext);
}
}
DemoService.registerClass('DemoService',Sys.Net.WebServiceProxy);
详细请看这里:http://www.netcsharp.cn/showtopic-536.aspx
回复

使用道具 举报

千问 | 2007-6-22 01:03:37 | 显示全部楼层
之前遇到一个要求,需要能够取消一个正在进行中的Web Service。这也是我第一次遇到这个功能,不过不难,我想。既然ASP.NETAJAX的客户端与服务器端通信完全通过Microsoft AJAX Library的异步通信层进行,那么我们只要得到正在请求WebService的Sys.Net.WebRequest对象,调用其abort方法就可以了。但是究竟应该如何得到这个对象呢?于是我粗略地阅读了一下代码。   首先假设有如下的Web Service方法定义(DemoService.asmx):
[ScriptService]
public class DemoService: System.Web.Services.WebService
{
[WebMethod]
public string DemoMethod()
{
return "Hello World";
}
}
  访问DemoService.asmx/jsdebug(或者将其使用ScriptManager引用到页面中之后)就能够得到如下的代理(片断、经过排版)类。
var DemoService = function()
{
DemoService.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
DemoService.prototype =
{
DemoMethodunction(succeededCallback, failedCallback, userContext)
{
return this._invoke(

DemoService.get_path(),

'DemoMethod',

false,

{},

succeededCallback,

failedCallback,

userContext);
}
}
DemoService.registerClass('DemoService',Sys.Net.WebServiceProxy);
详细请看这里:http://www.netcsharp.cn/showtopic-536.aspx
回复

使用道具 举报

千问 | 2007-6-22 01:03:37 | 显示全部楼层
web service是无状态的,所以不要考虑取消的问题了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行