SYSK 286: What Does a Web Service Proxy Look Like on a Client Side?

AJAX.NET makes it extremely simple to call a web service from a client using JavaScript…  But if you’re having problems, it helps to understand what your web service proxy looks like…


For example, if you have the following web service:


using System;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;


[WebService(Namespace = "")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]



public class MyService : System.Web.Services.WebService {


    public MyService ()






    public MethodXResult MethodX(string param1)


        return null;






public class MethodXResult


    private string _someProperty;


    [System.Runtime.Serialization.DataMember] public string SomeProperty


        get { return _someProperty; }

        set { _someProperty = value; }




then the client side JavaScript proxy would look something like this:


var MyService=function() {


this._timeout = 0;

this._userContext = null;

this._succeeded = null;

this._failed = null;



MethodX:function(param1,succeededCallback, failedCallback, userContext) {

return this._invoke(MyService.get_path(), 'MethodX',false,{param1:param1},succeededCallback,failedCallback,userContext); }}


MyService._staticInstance = new MyService();

MyService.set_path = function(value) { MyService._staticInstance._path = value; }

MyService.get_path = function() { return MyService._staticInstance._path; }

MyService.set_timeout = function(value) { MyService._staticInstance._timeout = value; }

MyService.get_timeout = function() { return MyService._staticInstance._timeout; }

MyService.set_defaultUserContext = function(value) { MyService._staticInstance._userContext = value; }

MyService.get_defaultUserContext = function() { return MyService._staticInstance._userContext; }

MyService.set_defaultSucceededCallback = function(value) { MyService._staticInstance._succeeded = value; }

MyService.get_defaultSucceededCallback = function() { return MyService._staticInstance._succeeded; }

MyService.set_defaultFailedCallback = function(value) { MyService._staticInstance._failed = value; }

MyService.get_defaultFailedCallback = function() { return MyService._staticInstance._failed; }


MyService.MethodX= function(param1,onSuccess,onFailed,userContext) {MyService._staticInstance.MethodX(param1,onSuccess,onFailed,userContext); }

var gtc = Sys.Net.WebServiceProxy._generateTypedConstructor;

if (typeof(MethodXResult) === 'undefined') {

var MethodXResult=gtc("MethodXResult");





To find out what your web service proxy looks like, navigate to your web service .asmx file followed by /js.  For example, http://localhost:56238/WebSite/MyService.asmx/js


You should get a File Download prompt…  Choose Save option, type in the file name, press Save button.  Then, use your favorite text editor to open and view contents of the saved file containing the JavaScript proxy generated for your web service…



Comments (1)

  1. Aftab yo says:

    Hey thanks very much for the kind article. It really helps a lot.

    I didn’t know about using the filename.asmx/js till now that opens the download dialog box for people to study source code.

    Thanks again!

Skip to main content