about Web.Network.createRequest(~~)

hi. i have a question about Web.Network.createRequest()
first of all .. my code..below..
=============================================================
var M_ObjHeaders = new Array();
M_ObjHeaders["Application-Key"] = "humbroll";
var request = Web.Network.createRequest(Web.Network.Type.XML, m_url, {proxy:"generic"}, callBack, M_ObjHeaders); alert("test12-0");
request.execute();
alert("test12-1");
=============================================================
test12-0 is popup. but test12-1 not.
i want to setting my header information in XMLHttpRequest with Web.Network.createRequest() method.
 my code is just follow API.. what's wrong
im very nervous about your answer.
please help me.gentleman.
good luck.
ps : sorry about my fool english~


Answer this question

about Web.Network.createRequest(~~)

  • Ming Zhao

    Actually, the timeout has been increased to 5 seconds.....as of today!
  • marcbo

    Thank you so much! this appears to have fixed some issues I was having with my gadget!!
  • accident

    To add to Rodcet's post, you should not only verify that your callback is actually being called, but that it's getting back something useful in response.responseXml. The easiest way to verify that is to attach a debugger (not so easy to read XML code in an alet() dialog).

    In fact, you may want to attach a debugger anyway, since my best guess here is that you're hitting an error inside of the createRequest code itself and live.com is swallowing the exception because it's not running in debug mode. That results in a code stoppage without any external indication that there was a problem beyond strange behavior (ie, no script warning in the corner of IE's status bar). If I had to guess, I'd say that the XML request type through the generic proxy probably doesn't like you setting headers.


  • Andy Johnston

    Without having your code I can't say for certain, but what you describe sounds exactly like what happens when the gadget framework eats an exception (which happens far too often for my liking -- it'd be nice to be able to flip a switch for debugging or not just by changing your manifest). My best guess is that the generic proxy doesn't like headers, which means you're SOL for using that web service.

    What can you do Since it seems you own the web service, you can change it to accept auth in a different manner. Or you could petition the Live.com developers to fix their proxies to support passing headers (many people have tried this to get XMLPost proxying, which still hasn't been implemented over a year later, so good luck on trying to get headers passed through the proxy).


  • dcroman

    Also, be aware that live.com and spaces do not communicate similarly with their respective proxy servers.

    A call to Web.Network.createRequest will almost always return a "200" response.status from the server regardless of the actual status of the response.

    As of right now, there is a hard timeout on the Spaces proxy of around 2 seconds. If your request hits this 2 second timeout your response status will be "200" and your response text will be " <error>invalid xml</error> "


  • bashok

    thanks for answers gentleman~.and sorry about my short question

    of course, there is callBack function in my code. my code below.

    ===========================================================
    var M_ObjHeaders = new Array();
    M_ObjHeaders["Application-Key"] = "app_key_for_humhum";



    function createXMLRequest(){
    m_url = "http://humhum.w3pad.com/pages/test format=xml";
    var request = Web.Network.createRequest(Web.Network.Type.XML,
    m_url,
    {proxy:"generic"},
    callBack,
    M_ObjHeaders);

    alert("test12-0");

    request.execute();

    alert("test12-1");
    }

    function callBack(response){
    alert("test13");
    if(response.status == 200){
    alert("test14");
    if(response.responseXML){
    alert("test15");
    var reXML = response.responseXML;
    var result = reXML.getElementsByTagName("text")[1].firstChild.nodeValue;
    alert(result);
    p_elSource.innerHTML += result;
    alert("SUCCESS");
    }
    }
    }
    =============================================================
    createXMLRequest() function is called in initialize function.

    M_ObjHeaders["Application-Key"] = "key_for_humbroll";
    -> "Application-Key" and "key_for_humbroll" is access key for openAPI that i use.

    dont popup alert("test12-1");
    of course. dont popup alert("test13"); and after alert also not popup.

    so. i write what i want .

    i must setting my header in reqeust for retrieve XML doc in m_url. request is GET method.

    how can i do that ..

    im sorry about my fool english. i hope you recognize my question ;-)

    good luck~








  • John CHLee

    Is that all of your code

    You are referencing "callBack" as you callback procedure.

    But I don't see the callBack function.

    In your example, you will need something like this..

    function callBack(response)

    {

     //response will contain the information brought back by your webservice call.

      alert('Is my callback function being called');

    }

    It would also be helpful if you post the m_url value.

     


  • about Web.Network.createRequest(~~)