locked
ServerXMLHTTP Returns HTML Error 404 But URL is Valid RRS feed

  • Question

  • User-981097093 posted

    Hello Folks!

    Env: XP PRO, WSH 5.7, JScript, IIS 6 WebServer
    I am stumped by a strange problem with a https link that works perfect when I use it in IE browser, but if I programmatically call it using ServerXMLHTTP, it returns http error 404 - resource missing. If I use the XMLHTTP object, it does return the results OK!

    We have SSL Cert issues so that is why I must use the serverXMLHTTP object. Any ideas why serverXMLHTTP fails with error 404 and XMLHTTP works ok?

    // testhttps.js - demo - GET page results for a URL
    var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0"); // Instantiate ver 6 ServerXMLHTTP
    objHttp.setOption(2, 13056);         // Ignore all SSL Cert issues
    var strUID = "******";
    var strPassw = "******";
    var strURL = "https://server1/ccmadmin/reports/trunkaccess.asp"; //debug
    // Build HTTP/1.1 Request
    objHttp.open("GET", strURL, false, strUID, strPassw); // GET Method, asynchronous=false
    WScript.Echo("Transmitting Request to \n[" + strURL + "] for UID[" + strUID + "]");

    try {
     objHttp.send(null);  //transmit GET request
    }
    catch(e) {
     strErrMsg = "HTTP Transmission Error!!! Error [" + e.number + "] [" + e.description + "]";
      WScript.Echo("Oooops-1");
    }

    WScript.Echo("Return HTTP Status=>" + objHttp.status);//debug

    if (objHttp.status == "200") {  //Return OK
     WScript.Echo("Yea - it works!!!");
     }
    else if (objHttp.status == "401") {  //Bad UID and/or password
     strErrMsg = "Credentials Error - Check UID and/or password.";
      WScript.Echo("Oooops-2");
     }
    else  {
     strErrMsg = "A critical HTTP Error has occurred. Status=[" + objHttp.status + "]"; //ugh - we got issues!
      WScript.Echo("Oooops-3");
     }
     


    Execution Results:

    >cscript testhttps.js
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.

    Transmitting Request to
    [https://server1/ccmadmin/reports/trunkaccess.asp] for UID[******]
    Return HTTP Status=>404
    Oooops-3


     

    Thursday, July 23, 2009 4:55 PM

Answers

  • User-981097093 posted

    RESOLVED!!!!!

    Thanks to everyone who replied with suggestions and comments - I really appreacite it as I "banged my head againt a wall for a week on this issue".

    The issue:

    When using the serverXMLHTTP object, it sends a generic User-Agent header such as

    "Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5)"; as revealed in the IIS logs. The remote server returned 404 because the asp page I was trying to access had some User-Agent code checking - which in turn redirected the request to a non-existent asp page - thus the final result was 404.

    The User-Agent was spoofed to IE7 and thus it resolved the issue; code follows:

    Force User-Agent to IE7
    var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0"); // Instantiate ver 6 ServerXMLHTTP
    objHttp.setOption(2, 13056);         // Ignore all SSL Cert issues
    objHttp.open("GET", strCUCMURL, false, strUID, strPassw); // GET Method, asynchronous=false
    objHttp.setRequestHeader("User-Agent", "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1)")  //specify IE 7 browser
    objHttp.send(null);  //transmit GET request

     

    Thanks everyone for all your help!!!!!

    Keith

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, July 26, 2009 1:31 PM

All replies

  • User-823196590 posted

    Any ideas why serverXMLHTTP fails with error 404 ... ?

    http://blogs.iis.net/tomkmvp/archive/2009/04/27/troubleshooting-a-404.aspx

    Thursday, July 23, 2009 5:46 PM
  • User-73836531 posted

    Is it working for when you use http:// instead of https:// ?

     

    Thursday, July 23, 2009 7:16 PM
  • User-981097093 posted

    Browsing the link directly using IE or Firefox works perfectly - it is an ssl link so one must use https.

    Programatically, using COM object XMLHTTP also works perfectly.

    However, due to some issues we have frequently with SSL Certs not being perfect, we must use the COM object serverXMLHTTP and disable server cert checking. When I use serverXMLHTTP it always returns error 404. I am going to get the web admin to get the IIS logs for me.

    Thursday, July 23, 2009 7:38 PM
  • User-823196590 posted

    Your original post says 404 and now you say 401 - which is it?

    Friday, July 24, 2009 7:18 AM
  • User-981097093 posted

    Sorry - I just edited the post - its 404.

    Friday, July 24, 2009 8:32 AM
  • User-981097093 posted

    Hello, I have some updates. The remote host I was accessing is a Cisco appliance running Win2000 Server and IISv5. I now have OS access to this server so I am able to look at IIS config and logs.

    Remote host is WIN2000 Server SP4 v5.00.2195 – IIS v5.0

    I ran two tests this moring.

    First time used COM object XMLHTTP – works OK!!

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>var objHttp = new ActiveXObject("Msxml2.XMLHTTP.6.0");<o:p></o:p><o:p> </o:p><o:p> </o:p>

    Second time used serverXMLHTTP – failed with error 404.

    var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");// Instantiate ver 6

     

     <o:p></o:p>objHttp.setOption(2, 13056);      // Ignore all SSL Cert issues<o:p></o:p><o:p> </o:p>

     

    The url I am targeting is:

    https://server1/ccmadmin/reports/devicelistxjs1.asp

    <o:p> </o:p>

    Script was run from my laptop with IP address 172.17.37.8 and here are all the log records I found:

    <o:p> </o:p>

    #Software: Microsoft Internet Information Services 5.0

    #Version: 1.0

    #Date: 2009-07-24 00:00:25

    #Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem cs-uri-query sc-status sc-win32-status cs(User-Agent) cs(Referer)

    <o:p> </o:p>

    These appear to be the log records associated with use of the XMLHTTP call that works ok:

    2009-07-24 16:03:29 172.17.37.8 - 10.28.18.89 443 GET /ccmadmin/reports/devicelistxjs1.asp - 401 5 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+.NET+CLR+2.0.50727;+MS-RTC+LM+8) -

     

    <o:p></o:p>2009-07-24 16:03:52 172.17.37.8 XXXXXX (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/devicelistxjs1.asp - 200 0 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+.NET+CLR+2.0.50727;+MS-RTC+LM+8) –<o:p></o:p><o:p> </o:p>

    The program using serverXMLHTTP returned code 404 and I also dumped the return headers too:

    [https://server1/ccmadmin/reports/devicelistxjs1.asp] for UID[XXXXXX]

    <o:p></o:p>CUCM Return HTTP Status=>404

     

    <o:p></o:p>Server: Microsoft-IIS/5.0

     

    <o:p></o:p>Date: Fri, 24 Jul 2009 16:04:23 GMT

     

    <o:p></o:p>Connection: close

     

    <o:p></o:p>Content-Type: text/html

     

    <o:p></o:p>Content-Length: 4040

     

    <o:p></o:p>A critical HTTP Error with CUCM has occurred. Status=[404]<o:p></o:p><o:p> </o:p><o:p> </o:p>

     

    These appear to be the log records associated with the use of serverXMLHTTP call that returned error 404:

    <o:p> </o:p>2009-07-24 16:04:23 172.17.37.8 - 10.28.18.89 443 GET /ccmadmin/reports/devicelistxjs1.asp - 401 5 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) -

     

    <o:p></o:p>2009-07-24 16:04:23 172.17.37.8 XXXXXX (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/devicelistxjs1.asp - 302 0 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) -

     

    <o:p></o:p>2009-07-24 16:04:23 172.17.37.8 XXXXXX (SQLSvc) (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/browserversion.asp b=&v=4.0|-|0|404_Object_Not_Found 404 0 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) –<o:p></o:p><o:p> </o:p><o:p></o:p> 

     

     

    <o:p></o:p><o:p> Any suggestions or ideas? would appreciate it!!</o:p><o:p>:)</o:p><o:p>Thanks,</o:p><o:p>Keith</o:p><o:p> </o:p>

     

    Friday, July 24, 2009 1:24 PM
  • User-823196590 posted

    kelunn

    var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0");// Instantiate ver 6

    Is this code running from an ASP or client side script?

    If this is client side scripting then we're in the wrong forum.

    kelunn

    2009-07-24 16:04:23 172.17.37.8 XXXXXX (SQLSvc) (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/browserversion.asp b=&v=4.0|-|0|404_Object_Not_Found 404 0 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) –  

    The 404 is occuring for browserversion.asp - how is that involved in this process?

    Friday, July 24, 2009 3:52 PM
  • User-1724662499 posted

    Inspecting the server logs is a very good idea.

    [EDIT]

    2009-07-24 16:04:23 172.17.37.8 XXXXXX (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/devicelistxjs1.asp - 302 0 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) -

    2009-07-24 16:04:23 172.17.37.8 XXXXXX (SQLSvc) (SQLSvc) 10.28.18.89 443 GET /ccmadmin/reports/browserversion.asp b=&v=4.0|-|0|404_Object_Not_Found 404 0 Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5) –

    HTTP code 302 is a redirect instruction (1) Where did that come from and why? (2) it redirects to browserversion.asp. Inspect you code (or google) to see is this happens intentionally or automatically.

    Saturday, July 25, 2009 3:40 AM
  • User-981097093 posted

    Hey Tom, I am actually running this as a JScript program under WSH. I could not find a forum for WSH so I chose this forum as having most relavency.

    Do you recommend I move the post to another forum - which one.

    And also, thanks for all your replies too!

    Keith

    Sunday, July 26, 2009 12:32 PM
  • User-981097093 posted

    RESOLVED!!!!!

    Thanks to everyone who replied with suggestions and comments - I really appreacite it as I "banged my head againt a wall for a week on this issue".

    The issue:

    When using the serverXMLHTTP object, it sends a generic User-Agent header such as

    "Mozilla/4.0+(compatible;+Win32;+WinHttp.WinHttpRequest.5)"; as revealed in the IIS logs. The remote server returned 404 because the asp page I was trying to access had some User-Agent code checking - which in turn redirected the request to a non-existent asp page - thus the final result was 404.

    The User-Agent was spoofed to IE7 and thus it resolved the issue; code follows:

    Force User-Agent to IE7
    var objHttp = new ActiveXObject("Msxml2.ServerXMLHTTP.6.0"); // Instantiate ver 6 ServerXMLHTTP
    objHttp.setOption(2, 13056);         // Ignore all SSL Cert issues
    objHttp.open("GET", strCUCMURL, false, strUID, strPassw); // GET Method, asynchronous=false
    objHttp.setRequestHeader("User-Agent", "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1)")  //specify IE 7 browser
    objHttp.send(null);  //transmit GET request

     

    Thanks everyone for all your help!!!!!

    Keith

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, July 26, 2009 1:31 PM