Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

XMLHTTPRequest: Run-Time Error on .Send Command

I am trying to submit an XML request object and subsequently receive an XML response object but cannot proceed past the "http.send reqDoc" command.

I receive two different errors messages when attempting to submit the XML object. The first message is produced on the following line of code:

http.send reqDoc

My system hangs for about 2 minutes on this line and then produces the following message:

Run-time error '-2146697208 (800c0008)':
The download of the specified resource has failed.

After I receive this message the application fails and I have to restart the application. After restarting the application the "http.send reqDoc" line executes but the http object indicates that the response XML object has not been received. It is at this point that I receive the second message which is:

Input Segments are Invalid

I believe that the "Input Segments are Invalid" message is on account of the XML string not being formatted properly, however, I am unsure why I only receive this message after I stop and restart the application.

Can anyone explain what is causing the first error message?

The VB code is as follows:

Private Sub BtnSubmit_Click()

' Build XML Object

' Create an empty DOM document
Dim reqDoc As MSXML2.DOMDocument40
Set reqDoc = CreateObject("Msxml2.DOMDocument.4.0")

' Post XML Object To Equifax

' Submit the request to the server
Dim a As Boolean
Dim http As MSXML2.XMLHTTP40
Set http = CreateObject("Msxml2.XMLHTTP.4.0")
http.open "POST", "https://www.website.com/processingpage.asp", False
reqDoc.Load ("C:\customerdata1.xml")
http.send reqDoc

' Check for HTTP errors
If http.Status <> 200 Then
' Complain about the error
TxtResults.Text = "HTTP Error " & http.Status & " (" & http.statusText & " occurred)"
Exit Sub
End If

' Get the response document from the server
Dim respDoc As MSXML2.DOMDocument40
Set respDoc = CreateObject("Msxml2.DOMDocument.4.0")
respDoc.setProperty "SelectionLanguage", "XPath"
respDoc.Load (http.responseStream)

' Check for XML parse errors
If respDoc.parseError.errorCode <> 0 Then
' Complain about the error
tmpString = "Invalid response: " & respDoc.parseError.reason & " at line " & respDoc.parseError.Line
Exit Sub
End If

End Sub
[2669 byte] By [A2Z] at [2007-11-11 6:33:55]
# 1 Re: XMLHTTPRequest: Run-Time Error on .Send Command
You probably want to use "Msxml2.FreeThreadedDOMDocument.4.0"
and set it to async = false, so that it will be assured that it is fully loaded during the .Load( ) before you attempt to send it.
KC-Luck at 2007-11-11 23:28:48 >
# 2 Re: XMLHTTPRequest: Run-Time Error on .Send Command
Thanks KC... I will try that and let you know.

I was able to fix the second error message by changing all quotations in the XML body from single quotes to double quotes but am still receiving the first message!

Hopefully what you suggest will work...

Thanks,
A2Z
A2Z at 2007-11-11 23:29:55 >