Generated WebSeviceProxy Bug?

Last post 07-14-2007 11:19 AM by KaziManzurRashid. 6 replies.

Sort Posts:

  • Generated WebSeviceProxy Bug?

    07-12-2007, 7:23 PM
    • Contributor
      4,792 point Contributor
    • KaziManzurRashid
    • Member since 03-09-2003, 11:04 AM
    • Dhaka, Bangladesh
    • Posts 882

    I am not sure whether it is intentional or not, but it certainly needs some attention.


    My actual goal was to abort a Web Method Call after it has been invoked. We know that all kinds of Client Side Web Service Proxy are inherited from Sys.Net.WebServiceProxy class. This class contains a single method invoke which is used to call the server side method. The Ajax Documentation specifies that invoke method returns a Sys.Net.WebRequest class, which is used to call the method as well as aborting the call. So I came with following code:

    var _webRequest = null;
    
    function invokeMethod()
    {
        _webRequest = DataService.LongOperation  (  10000, //10 seconds
                                                    function(result)
                                                    {
                                                        alert(result);
                                                        $get('btnInvoke').disabled = false;
                                                        $get('btnAbort').disabled = true;
                                                    },
                                                    function(exception)
                                                    {
                                                        alert(exception.get_message());
                                                        $get('btnInvoke').disabled = false;
                                                        $get('btnAbort').disabled = true;
                                                    }
                                                );
        //_webRequest is undefined here !!!!
        $get('btnInvoke').disabled = true;
        $get('btnAbort').disabled = false;
    }
    
    function abortMethod()
    {
        if (_webRequest != null)
        {
            var executor = _webRequest.get_executor();
    
            if (executor.get_started())
            {
                executor.abort();
            }
    
            $get('btnInvoke').disabled = false;
            $get('btnAbort').disabled = true;
        }
    }

    But unfortunatly I found that the _webRequest is undefined. So I did a /js thing to generate the proxy:
    var DataService=function() {
    DataService.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null;
    }
    DataService.prototype={
    LongOperation:function(miliseconds,succeededCallback, failedCallback, userContext)
    {
    	return this._invoke(DataService.get_path(), 'LongOperation',false,{miliseconds:miliseconds},succeededCallback,failedCallback,userContext);}
    }
    DataService.registerClass('DataService',Sys.Net.WebServiceProxy);
    DataService._staticInstance = new DataService();
    //Removed the other parts for clarity DataService.LongOperation= function(miliseconds,onSuccess,onFailed,userContext) { DataService._staticInstance.LongOperation(miliseconds,onSuccess,onFailed,userContext); }

    What I understand looking at the above code, the proxy contains a self instance as _staticInstance which is basically used to invoke the method (The Prototype seciton) and it returns the WebRequest properly. But what I do not understand why override function does not inculde the return keyword. it should be like this:
    DataService.LongOperation= function(miliseconds,onSuccess,onFailed,userContext)
    {
    	return DataService._staticInstance.LongOperation(miliseconds,onSuccess,onFailed,userContext);
    }

    So to get the WebRequest I have to call the DataService._staticInstance.LongOperation instead of DataService.LongOperation().

    Can any of the Ajax Team members shed a light on this? Is it a bug or intentional, if it is intentional then what is the reason?
    Long Live .NET
    Kazi Manzur Rashid (Amit)
    _________________________
    Web: http //dotnetshoutout.com
    Blog: http://weblogs.asp.net/rashid
    Twitter: http://twitter.com/manzurrashid
  • Re: Generated WebSeviceProxy Bug?

    07-13-2007, 5:48 PM
    • Contributor
      4,792 point Contributor
    • KaziManzurRashid
    • Member since 03-09-2003, 11:04 AM
    • Dhaka, Bangladesh
    • Posts 882

    Can anyone form MS Ajax Team shade a light on this?

    Long Live .NET
    Kazi Manzur Rashid (Amit)
    _________________________
    Web: http //dotnetshoutout.com
    Blog: http://weblogs.asp.net/rashid
    Twitter: http://twitter.com/manzurrashid
  • Re: Generated WebSeviceProxy Bug?

    07-13-2007, 5:53 PM
    • Contributor
      2,460 point Contributor
    • Steve Marx
    • Member since 05-26-2006, 8:35 PM
    • Microsoft
    • Posts 643

    Are you using ASP.NET AJAX 1.0?  I just took a look at the proxy for one of my methods, and it looked very different and did indeed return the object you need.

    Steve Marx | ASP.NET AJAX Evangelist | Microsoft Corporation
  • Re: Generated WebSeviceProxy Bug?

    07-13-2007, 6:34 PM
    • Contributor
      4,792 point Contributor
    • KaziManzurRashid
    • Member since 03-09-2003, 11:04 AM
    • Dhaka, Bangladesh
    • Posts 882

    Yes I am

    Long Live .NET
    Kazi Manzur Rashid (Amit)
    _________________________
    Web: http //dotnetshoutout.com
    Blog: http://weblogs.asp.net/rashid
    Twitter: http://twitter.com/manzurrashid
  • Re: Generated WebSeviceProxy Bug?

    07-13-2007, 9:48 PM
    • Contributor
      4,792 point Contributor
    • KaziManzurRashid
    • Member since 03-09-2003, 11:04 AM
    • Dhaka, Bangladesh
    • Posts 882
    Long Live .NET
    Kazi Manzur Rashid (Amit)
    _________________________
    Web: http //dotnetshoutout.com
    Blog: http://weblogs.asp.net/rashid
    Twitter: http://twitter.com/manzurrashid
  • Re: Generated WebSeviceProxy Bug?

    07-14-2007, 8:54 AM
    • Contributor
      2,460 point Contributor
    • Steve Marx
    • Member since 05-26-2006, 8:35 PM
    • Microsoft
    • Posts 643

    Oh, sorry, I was confused... now I see the code you're talking about.

    Strange, this seemed familiar, but I couldn't remember what the solution was.  I searched on the web for it and came across a page (http://blogs.msdn.com/irenak/archive/2007/03/19/sysk-309-how-to-cancel-a-web-service-request.aspx) which suggested using "new MyService().MethodX(...)" instead of "MyService.MethodX(...)", since that will return the request object.  Oddly enough, the bottom of the post says "Special thanks to Steve Marx for the information," so that must be why I vaguely remember it. :-)

    Unfortunately, I don't remember the details of why this is the case.

    Steve Marx | ASP.NET AJAX Evangelist | Microsoft Corporation
  • Re: Generated WebSeviceProxy Bug?

    07-14-2007, 11:19 AM
    Answer
    • Contributor
      4,792 point Contributor
    • KaziManzurRashid
    • Member since 03-09-2003, 11:04 AM
    • Dhaka, Bangladesh
    • Posts 882

    Steve,

    I have already solved it check my blog from the above link, The Issue was why the Proxy is generated like this, is it intentional, if so what is the reason, if not then it must be a bug which needs to be fixed in future version or a patch must be released.

    Again thanks for your effort.

    Long Live .NET
    Kazi Manzur Rashid (Amit)
    _________________________
    Web: http //dotnetshoutout.com
    Blog: http://weblogs.asp.net/rashid
    Twitter: http://twitter.com/manzurrashid
Page 1 of 1 (7 items)