ASP.NET AJAX Web Service Proxies

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.

No Comments