Forum Discussion

paulvinders's avatar
paulvinders
Contributor
5 years ago
Solved

Calling webservices

Hi,

 

w're calling urls in the appserver in the following way:

function verifyUrl(url) {
  var httpObj = Sys.OleObject("MSXML2.ServerXMLHTTP.6.0");
  httpObj.open("GET", url, true);
  httpObj.send();
  while (httpObj.readyState != 4) {
    Delay(500);
    httpObj.send();
  }
  return httpObj.status == 404 ? false: true;
}

 

This worked fine in TC11. In TC 14.0 the test stays in the while loop...Is this approach not supported anymore?

 

sincerely

Paul Vinders

SOPTIM AG

Germany

  • The solution is:

     

      httpObj.open("GET", url, false);

     

    instead of

     

      httpObj.open("GET", url, true);

     

    sincerely

    P. Vinders

    SOPTIM AG

4 Replies

  • cunderw's avatar
    cunderw
    Community Hero

    I'm not sure why that functionality would have changed, but you might look into using the new built in aqHttp scripting objects. We have had better luck using that.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    If I am not mistaken, httpObj.readyState can return either a number or text value. ('complete' in your case)

    Try to put a breakpoint on the Delay() line and inspect the value of the httpObj.readyState property.

     

    P.S. BTW, it is not needed to resend the request within the while loop because:

    a) you are issuing request synchronously (httpObj.open("GET", url, false); ) which means that .open() will not return until the response is received; and

    b) .send() within the loop will create not necessary significant load on the web server if the response is not received within 500ms (as per your code) and request is sent asynchronously (httpObj.open("GET", url, true); ).

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thank you Alex, cunderw. 

      Hi paulvinders , did you find a way to solve this? Please share your progress with us! 

      • paulvinders's avatar
        paulvinders
        Contributor

        The solution is:

         

          httpObj.open("GET", url, false);

         

        instead of

         

          httpObj.open("GET", url, true);

         

        sincerely

        P. Vinders

        SOPTIM AG