ServerXMLHTTP Returns HTML Error 404 But URL is Valid [Answered]RSS

10 replies

Last post Jul 26, 2009 01:31 PM by kelunn

  • ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 23, 2009 04:55 PM|kelunn|LINK

    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


     

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 23, 2009 05:46 PM|tomkmvp|LINK

    kelunn

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

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

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 23, 2009 07:16 PM|thewebhostingdir|LINK

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

     

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 23, 2009 07:38 PM|kelunn|LINK

    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.

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 24, 2009 07:18 AM|tomkmvp|LINK

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

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 24, 2009 08:32 AM|kelunn|LINK

    Sorry - I just edited the post - its 404.

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 24, 2009 01:24 PM|kelunn|LINK

    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!!

     var objHttp = new ActiveXObject("Msxml2.XMLHTTP.6.0");  

    Second time used serverXMLHTTP – failed with error 404.

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

     

     objHttp.setOption(2, 13056);      // Ignore all SSL Cert issues 

     

    The url I am targeting is:

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

     

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

     

    #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)

     

    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) -

     

    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) – 

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

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

    CUCM Return HTTP Status=>404

     

    Server: Microsoft-IIS/5.0

     

    Date: Fri, 24 Jul 2009 16:04:23 GMT

     

    Connection: close

     

    Content-Type: text/html

     

    Content-Length: 4040

     

    A critical HTTP Error with CUCM has occurred. Status=[404]  

     

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

     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) -

     

    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) –  

     

     

     Any suggestions or ideas? would appreciate it!!:)Thanks,Keith 

     

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 24, 2009 03:52 PM|tomkmvp|LINK

    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?

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 25, 2009 03:40 AM|salman_arshad|LINK

    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.

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 26, 2009 12:32 PM|kelunn|LINK

    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

  • Re: ServerXMLHTTP Returns HTML Error 404 But URL is Valid

    Jul 26, 2009 01:31 PM|kelunn|LINK

    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