ASP.NET AJAX Web Service Proxies

Published Tuesday, October 24, 2006 11:43 PM

You have no doubt seen the multitude of posts talking about some of the many changes in the beta release of the ASP.NET AJAX libraries compared to the CTP releases.

Well, here is another....

Below is a CTP generated proxy of a web service:

Type.registerNamespace('Test'); Test.SampleService=new function() { this.appPath = "http://localhost:2455/AtlasServerControls/"; var cm=Sys.Net.ServiceMethod.createProxyMethod; cm(this,"HelloServer"); cm(this,"Search","prefixText","count"); }

And here is a Beta 1 generated proxy of the same web service:

Type.registerNamespace('Test');
Test.SampleService=function() {
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
Test.SampleService.prototype={
HelloServer:Sys.Net._WebMethod._createProxyMethod(this,"HelloServer", "Test.SampleService.HelloServer",false),
Search:Sys.Net._WebMethod._createProxyMethod(this,"Search", "Test.SampleService.Search",false,"prefixText","count"),_get_path: function() { return Test.SampleService.get_path(); },
set_timeout: function(value) { this._timeout = value; },
get_timeout: function() { return this._timeout; },
set_defaultUserContext: function(value) { this._userContext = value; },
get_defaultUserContext: function() { return this._userContext; },
set_defaultSucceededCallback: function(value) { this._succeeded = value; },
get_defaultSucceededCallback: function() { return this._succeeded; },
set_defaultFailedCallback: function(value) { this._failed = value; },
get_defaultFailedCallback: function() { return this._failed; }
}
Test.SampleService._staticInstance = new Test.SampleService();
Test.SampleService.set_path = function(value) { Test.SampleService._staticInstance._path = value; }
Test.SampleService.get_path = function() { return Test.SampleService._staticInstance._path; }
Test.SampleService.set_timeout = function(value) { Test.SampleService._staticInstance._timeout = value; }
Test.SampleService.get_timeout = function() { return Test.SampleService._staticInstance._timeout; }
Test.SampleService.set_defaultUserContext = function(value) { Test.SampleService._staticInstance._userContext = value; }
Test.SampleService.get_defaultUserContext = function() { return Test.SampleService._staticInstance._userContext; }
Test.SampleService.set_defaultSucceededCallback = function(value) { Test.SampleService._staticInstance._succeeded = value; }
Test.SampleService.get_defaultSucceededCallback = function() { return Test.SampleService._staticInstance._succeeded; }
Test.SampleService.set_defaultFailedCallback = function(value) { Test.SampleService._staticInstance._failed = value; }
Test.SampleService.get_defaultFailedCallback = function() { return Test.SampleService._staticInstance._failed; }
Test.SampleService.set_path("/ASPNET_AJAX_ServerControls/WebServices/SampleService.asmx");
Test.SampleService.HelloServer= function(onSuccess,onFailed,userContext) {Test.SampleService._staticInstance.HelloServer(onSuccess,onFailed,userContext); }
Test.SampleService.Search= function(prefixText,count,onSuccess,onFailed,userContext) {Test.SampleService._staticInstance.Search(prefixText,count,onSuccess,onFailed,userContext); }

Big difference.

About the only thing the same iin both s the first line. Note the use of the prototype pattern in the new proxy. While not only remaining consistent with the current library and associated patterns for constucting objects, this will be more important once Orcas is available and the improved debugging experience allows us to peer inside these proxies.

by Glav
Filed under: , ,

Comments

# ryan said on Tuesday, October 24, 2006 10:52 AM

yes

# Arthur Hill said on Saturday, November 07, 2009 7:00 PM

arthurleehill@gmail.com

Help, I am working my way thru the ASP.Net tutorials on AJAX.  I created a WebMethod

   [WebMethod]

   public string ConcatHello(string NameIn)

   {

       return "Hello World " + NameIn;

   }

When I go to call it in a javascript function I get the following required parameters (String,onSuccess,onFailed,userContext)

The last 3 obviously coming from the proxy prototype in your blog.  

What values are to be entered for the last three parameters.  The video I am watching is obviously out of date and I am stuck.  

Thanks for your help.

Art

Leave a Comment

(required) 
(required) 
(optional)
(required) 

This Blog

Syndication