[CLOSED] Ext.net.DirectMethod.request webservice call and isUpload

  1. #1

    [CLOSED] Ext.net.DirectMethod.request webservice call and isUpload

    Hi

    Using the examples https://examples2.ext.net/#/Events/D...ds/WebService/

    I am calling a WebService Endpoint from a DirectMethod, only difference is my service returns the actual file for download from the asmx file. Here is the function and I've tested it without problem by called it directly.

    
     [WebMethod]
            public void DownloadScript(string script)
            {
             
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Charset = "UTF-16";
                    HttpContext.Current.Response.ContentType = "application/x-pmt; charset=\"UTF-16\"";
                    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename="+ ts.Name+ ".pmt");
                    HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
                    HttpContext.Current.Response.Write(script);
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.End();
    
              
            }

    I know I need isUpload = true somewhere, otherwise I'm going to get BadResponse. However doesn't matter if I put isUpload or not in the following code, it still return BADRESPONSE: Cannot read property 'documentElement' of null

       MyControl.Listeners.Click.Handler = @"
                             Ext.net.DirectMethod.request({
                                            url          : '/TestScriptWS.asmx/DownloadScript',
                                            isUpload     : true,
                                            cleanRequest : true,
                                            json         : true,   
                                            params       : {                                           
                                                script : '1234'
                                            }
                                        });
                          ";

    It seems that DirectMethod.request doesn't read that isUpload parameter.... where should I put that? I've spend long time trying to figure that out but no joy. Thank you very much
    Last edited by Daniil; Sep 28, 2012 at 9:12 AM. Reason: [CLOSED]
  2. #2
    Hi @CarpFisher,

    AJAX downloading requires a <form>.

    Please define a <form>.
    <form id="form1" class="x-hidden"></form>
    and refer it in the DirectMethod config
    formId: "form1"
  3. #3
    not working :(

    I've got this error after formId is defined

    System.InvalidOperationException: Request format is invalid: multipart/form-data; boundary=----WebKitFormBoundaryiCoYwSAmMGdO8yW4.
       at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
       at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

    Am I missing anything?
  4. #4
    This is the info I've got from Chrome's developer tool


    Request URL:http://localhost:3269/WebServiceHandlers/TestScriptWS.asmx/DownloadScript
    Request Method:POST
    Status Code:500 Internal Server Error
    
    
    Request Headers:
    
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
    Accept-Encoding:gzip,deflate,sdch
    Accept-Language:en-US,en;q=0.8
    Cache-Control:max-age=0
    Connection:keep-alive
    Content-Length:381
    Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryXPeMdCUDo9oWvW0x
    Cookie:ASP.NET_SessionId=kwqsu2lgddynenalgx2iqcsn
    Host:localhost:3269
    Origin:http://localhost:3269
    Referer:http://localhost:3269/
    User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4
    Request Payload
    ------WebKitFormBoundaryXPeMdCUDo9oWvW0x
    Content-Disposition: form-data; name="__EVENTTARGET"
    
    ResourceManager1
    ------WebKitFormBoundaryXPeMdCUDo9oWvW0x
    Content-Disposition: form-data; name="__EVENTARGUMENT"
    
    -|public|Click
    ------WebKitFormBoundaryXPeMdCUDo9oWvW0x
    Content-Disposition: form-data; name="{%22ScriptID%22:3}"
    
    
    ------WebKitFormBoundaryXPeMdCUDo9oWvW0x--
    Response Headers:
    
    Cache-Control:private
    Content-Length:281
    Content-Type:text/plain; charset=utf-8
    Date:Thu, 27 Sep 2012 18:27:31 GMT
    Server:Microsoft-IIS/7.5
    X-AspNet-Version:4.0.30319
    X-Powered-By:ASP.NET
    X-SourceFiles:=?UTF-8?B?QzpcdGZzXFNvdXJjZSAtIFVBVFxQTVBUZXN0XFBNUFRlc3RNYXN0ZXJTZXJ2ZXJXZWJcV2ViU2VydmljZUhhbmRsZXJzXFRlc3RTY3JpcHRXUy5hc214XERvd25sb2FkU2NyaXB0?=
  5. #5
    It is not Ext.Net problem

    You can read about the issue
    http://www.developersalley.com/blog/...-from-PHP.aspx
    http://forums.asp.net/t/1551950.aspx/1
    http://stackoverflow.com/questions/2...ipart-form-dat

    Solution: do not use parameters in WebMethod, read passed parameters manually from Request object
  6. #6
    Thank you it works. Just a little thing to note that I have to use
     json: false
    otherwise the variable name in the form will be a json object and you can't really retrieve that from the Request object in the usual way.
  7. #7
    By the way, false is by default. You can just omit this.

Similar Threads

  1. Replies: 7
    Last Post: Nov 29, 2011, 7:07 AM
  2. [CLOSED] [1.2] Force request from WebService-ComboBox
    By FVNoel in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 22, 2011, 12:35 PM
  3. [CLOSED] DirectMethods.Request+webservice
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 06, 2011, 7:13 AM
  4. Replies: 10
    Last Post: Apr 30, 2010, 5:42 PM
  5. [CLOSED] How to get Jason request from WebService
    By acrossdev in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 22, 2009, 9:59 AM

Tags for this Thread

Posting Permissions