MSXML2.XMLHTTP.4.0

Worked around a nasty issue on an ASP site today, I’m was using the MSXML2.XMLHTTP.4.0 object to post an XML packet to a SOAP server. Worked great on our development and staging servers, but I installed it (the app) on the client server today and get this… calling the send() method completely hangs IIS, you can’t stop the service, you can’t restart the service. Here’s the code snippet in question:

Dim objHTTP
Set objHTTP = Server.CreateObject(“Msxml2.XMLHTTP.4.0”)
objHTTP.open “POST”, “http://yourhost/endpoint.do”, false
objHTTP.setRequestHeader “Content-Type”, “text/xml”
objHTTP.setRequestHeader “SOAPAction”, “urn:myserver/soap:ThisName/thisMethod”
objHTTP.send xmlpacket
strReturn = objHTTP.responseXML.xml

The behavior I’m seeing is that the HTTP request doesn’t even get sent to the remote server, the IIS process becomes unusable, and restarting the W3/IISAdmin services don’t work. I’m using MSXML 4.0 Service Pack 2 (available here).

22 thoughts on “MSXML2.XMLHTTP.4.0”

  1. Hi did you find any solution to this problem?.
    We are facing exactly the same problem.

    We are using Coldfusion. and MsXml send method just hangs.

    your feedback is deeply appreciated.

    thank you,
    -Michael

  2. hey Michael,

    The only solution I found to the problem was to use the Microsoft.XMLHTTP object instead of the MSXML2.XMLHTTP.4.0 object. I was working in an ASP environment at that time, so that solution worked for me… hopefully it’ll work for you in CFMX as well.

    AJ

  3. I had “hang on second send” problem untill
    i remembered to close the socket on the server
    side, after having send the soap response.

  4. I am using this:

    Public Function SendRecieveHTTP(pstrURL, pstrMsgType, pstrXMLReqMsg)
    Dim lobjXMLHTTPObj, lstrACKMessage
    Dim lstrURL

    lstrURL = Cstr(ReadIni(gstrINIFile, “HTTPPATH”, “Path” & gintICtr)) ‘This can be commented since it already is being sent with URL
    lstrURL = lstrURL & “?FrancID=” & gstrFranchiseID & “&MsgTyp=” & pstrMsgType

    Set lobjXMLHTTPObj = CreateObject(“MSXML2.XMLHTTP”)
    CheckError(“Instantiating XML Object”)

    lobjXMLHTTPObj.Open “POST”, lstrURL, False
    CheckError(“HTTP Connection installation”)

    lobjXMLHTTPObj.Send pstrXMLReqMsg
    Msgbox pstrXMLReqMsg
    CheckError(“SENT CONNECTION INSTALL MESSAGE”)
    ‘LogEvent(“Send Message Attempt No : ” & gintJCtr & ” of ” & gintURLRetryCnt)
    LogEvent(RetHttpMessage(lobjXMLHTTPObj.status))

    SendRecieveHTTP = lobjXMLHTTPObj.responseText
    CheckError(“RECIEVE ACK MESSAGE”)

    Set lobjXMLHTTPObj = Nothing
    End Function

    and it works Fine!!

    See if you guys can churn something out of it!!

    To my understanding Except the IIS/Web server there shouldn’t be any other problem

    To check that my Web server is healthy I use this ASP code:

    Hope this helps

  5. Sorry My Test Web server Code was eaten up, trying again:

    Dim xo, var

    Set xo = Server.CreateObject(“MSXML2.XMLHTTP”)
    ‘xo.open “POST”, “http://P1055604:password@02537D0004648/IFB/RecieveMsg.asp?FrancID=9328&MsgTyp=CONNINSTALLREQ”, False
    xo.open “GET”, “http://P1055604:password@localhost:81/IFB/RecieveMsg.asp”, False

    xo.send “TESTDATATESTDATATESTDATATESTDATATESTDATATESTDATA”
    var = xo.responseText
    Response.Write “From Here—-” & var & ” —TILL HERE”

    Good Luck!!

  6. <%
    Response.Buffer = True
    Dim objXMLHTTP, xml
    Set xml = Server.CreateObject(“Microsoft.XMLHTTP”)

    ‘ Notice the two changes in the next two lines:
    xml.Open “POST”, “http://www.semnan.medu.ir/search.asp”, False
    xml.Send “q=irphc&s=all”
    Response.Write xml.responseText
    Set xml = Nothing
    %

  7. Have you tried using the “MSXML2.ServerXMLHTTP.4.0” object?

    (from memory) the regular XMLHTTP object isn’t quite as robust since it was designed more for client side rather than server side use.

  8. i used to get this problem with Microsoft.XMLHTTP, it worked about 10 times a day and then every app on the server that used it after that just hung.

    switching to Msxml2.ServerXMLHTTP totally fixed this, i looked into it and its actually the same as Msxml2.ServerXMLHTTP.3.0 on my server as i dont have 4.0 installed, i believe Msxml2.ServerXMLHTTP just runs the highest one you have

  9. I have gotten all the above problems..the last one i ended up with is nothing being displayed.
    This is the code:

    Dim xml
    Set xml = Server.CreateObject(“Microsoft.XMLHTTP”)

    On Error Resume Next

    xml.Open “GET”, “http://www.rss.cnn.com/rss/cnn_world.rss”, false

    xml.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded”

    If err.Number <> 0 Then
    Response.write Err.Description
    End If

    xml.send

    Response.write “Here’s the html we now have in our xml object”
    Response.write “”
    Response.Write “”
    Response.Write xml.responseText
    Response.Write “”
    Response.write “”
    Response.write ” Now here’s how the page looks:”
    Response.Write xml.responseText

    Set xml = Nothing
    %>

    Strangly it works with firefox for local and external url’s but IE only works for local url’s..Is this possibly a security issue in IE.Has anyone experienced these problems before? Assistance is appreciated.

  10. Ian, I think the issue with your script may be the 5th line, xml.setRequestHeader “Content-Type”, “application/x-www-form-urlencoded” . I was having a similiar problem using the post method with the text/xml and switched it to application/x-www-form-urlencoded and that fixed it. Try using text/xml instead.

  11. OK – It took a while but I finally sussed why ServerXMLHTTP.4.0 didn’t seem to like POSTing data…

    It seems the optional Send() parameter accepts 2 formats, either XML or the traditional GET string.

    I used the latter (it’s simpler to code) and below is how I formatted the string ready to ‘POST’ to my remote URL…

    sResult = “”
    For Each sTemp In Request.Form
    sResult = sResult & “&” & sTemp & “=” & Server.UrlEncode(Request.Form(sTemp))
    Next
    If Len(sResult) > 0 Then
    sResult = “?” & Mid(sResult, 2)
    End If
    ‘ Note that the String is EXPECTED to start with a question mark!!!
    Now you can submite using…
    oXMLHTTP4.Send(sResult)

    Ta daa….

  12. This might be the reason for IIS becoming unstable …
    ——-
    If pooling is set to Low or Medium (this is the default for Microsoft Windows 2000), you should POST to an ASP in a different virtual folder. If the ASP is in the same virtual folder, the ASP stops responding (hangs). After you close the browser, that ASP and other ASPs continue to hang because the request stays queued even though you close the browser. You must restart IIS or restart the computer.
    ——-
    Check this:
    http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q290591&ID=KB;EN-US;Q290591

  13. Same problem here. My code is same as most all posted here:

    Set btl_http = CreateObject(“Msxml2.ServerXMLHTTP.6.0”)
    btl_http.settimeouts 5000, 5000, 15000, 15000
    btl_http.Open “GET”, btl_url, False
    btl_http.Send

    If btl_http.readyState 4 Then
    btl_http.waitForResponse 60
    End If

    If btl_http.readyState 4 Or btl_http.Status 200 Then
    Goto failed_btl
    End If

    I have tried both methods POST and GET. SetTimouts has no effect. I have tried the XMLHTTP and here serverxmlhttp. I have stepped through each line and determined it does not progress beyond send.

    When attempting to access the site with a browser it just hangs there and then gives the not able to connect page. Browser in use is IE7. What I believe we all need is whatever scrap of code makes IE kick out when in this situation.

    If anyone has any answers to this jewel I would be eternally grateful.

  14. I had the same problem on a site I was working on for a customer. I resolved it by removing the version specific information from Msxml2.XMLHTTP. Once I did that, everything worked like a charm.

  15. How do we automate downloading of internet files in Excel VBA with the use of MSXML2. XMLHTTPO thing?
    I need to deliver something to the customer and its urgent.

  16. Here is the code segment in which i face difficulty in creating object. Object is not created. I am using MS Vista Business as OS.
    Set objXMLHTTP = CreateObject(“MSXML2.XMLHTTP.4.0”)
    objXMLHTTP.Open “GET”, strURL, false
    objXMLHTTP.Send

    But this code works on other machine with vista. Please help me.

  17. The code works fine for me.
    But i want to pass a variable to the web-method in the web service while calling it.
    How do we pass values to the function of a web service while calling it in asp?

Leave a Reply

Your email address will not be published. Required fields are marked *