A detail of client access to Web service methods

Source: Internet
Author: User

There was a requirement that you would be able to cancel an ongoing web Service. This is the first time I have ever met this function, but it's not difficult, I think. Now that asp.net AJAX client and server-side communication is done entirely through the asynchronous communication layer of the Microsoft Ajax Library, we simply get the request for Web Service Sys.Net.WebRequest object, call its Abort method on it. But how exactly should this object be obtained? So I read the code roughly.

First, suppose the following Web service method definition (demoservice.asmx):

[ScriptService]
public class DemoService : System.Web.Services.WebService
{
  [WebMethod]
  public string DemoMethod()
  {
    return "Hello World";
  }  
}

Accessing the Demoservice.asmx/jsdebug (or after using ScriptManager references to the page) will enable you to get the following proxy (fragment, typesetting) class.

var DemoService = function()
{
  DemoService.initializeBase(this);
  this._timeout = 0;
  this._userContext = null;
  this._succeeded = null;
  this._failed = null;
}
DemoService.prototype =
{
  DemoMethod:function(succeededCallback, failedCallback, userContext)
  {
    return this._invoke(
      DemoService.get_path(),
      'DemoMethod',
      false,
      {},
      succeededCallback,
      failedCallback,
      userContext);
  }
}
DemoService.registerClass('DemoService',Sys.Net.WebServiceProxy);
...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.