Strange behaving XMLHTTP

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone

I am trying to get the content of any webpage (URL) using XMLHTTP, and it
is working fine for me, but suddenly I have got

a URL "http://www.bizrate.com/" which is causing a system error and the
error is

System.Runtime.InteropServices.COMException(0xC00CE56E): System error:-
1072896658

here is the code, which I am using to get the content

''''''''''''''''''''''''''''''''''''''''''''''
Dim a As Object
a = CreateObject("Microsoft.XMLHTTP")
a.open("GET","http://www.bizrate.com/",False)
a.Send("")
TextBox1.Text = a.ResponseText
''''''''''''''''''''''''''''''''''''''''''''''

Can anybody help me to solve this problem, I have tried it using VB6 also,
and VB6 is also showing the same error.

One more thing I want to say about this, is that, I have got the content of
the URL "http://www.bizrate.com/" by typing the

address into the addressbar of the browser (IE), and got the HTML from
view->source, and then saved the HTML into my

localhost and changed the URL by "http://localhost/testpage.html and the
application worked for me, but it is not working

when the URL is used with XMLHTTP

Kajol
 
Here is a snippet in C# that I extracted from a project on GotDotNet,
showing you how to do this using a .NET object, instead of a COM component.

This was extracted from
http://www.gotdotnet.com/Community/...mpleGuid=DB30109D-5161-4713-B6A5-ED43CC83A68C
SiteMap 1.1 HTML Page Scraper (PageScanner.cs)

Hope this helps,
--- Nick

HttpWebRequest request;
HttpWebResponse response;
request = (HttpWebRequest)WebRequest.Create( url );
// *** BLOCK THREAD ***
response = (HttpWebResponse)request.GetResponse();

try {

// Read the response into a Stream object.
Stream responseStream = response.GetResponseStream();
if( responseStream == null ) {
throw new ApplicationException( "Server sent empty response stream
for "+url );
}


StreamReader reader=null;
try{
reader = new StreamReader( responseStream,
System.Text.Encoding.Default );

// *** BLOCK THREAD *** - until whole stream is read.
htmlText = reader.ReadToEnd(); // read in the web page

} catch( System.ArgumentOutOfRangeException ex) {
// this resolves back to the StreamReader having a byteCount of <
0 for its input buffer
// is caused by the connection failing with this exception in the
response
//IOException: Unable to read data from the transport connection
// Maybe the TcpConnect in just failed?
// anyway retry

throw ex;
} catch(Exception ex ) {
throw ex;
} finally{
if( reader != null ) reader.Close(); // manual clean up required or
will run out of WebHttp resources
}


} catch(Exception ex ) {
throw ex;
} finally{
response.Close(); // Release the HttpWebResponse resource. if we fail
to do this we may run out of connections
}
 
Thanks for the reply
I have tested with this .NET object and it is working fine
for the URL I have spacified, but can u do the same thing
for me using XMLHTTP, because I have developed a lot of my
project by XMLHTTP and at this point I do not want to
change from XMLHTTP to webreq/res

Kajol
 
IMHO, It would be easier to use a Facade pattern.

Create an internal object, of your own, that behaves just like XMLHTTP.
Give it the same properties and methods as XMLHTTP (but only the ones that
you actually use... don't bother with the rest). Within your own object,
call the .NET object to do the actual work.

Then, go through your code. In every place where you are creating an
XMLHTTP, create one of your internal objects instead. Change only the
declaration and the "create object" call. Leave the rest. When you
recompile your app, you will be free of XMLHTTP.

Sorry, I can't provide code to make XMLHTTP work. I haven't used that
object in about three years, and even then, only lightly. I'm no expert in
solving problems with it. If you are determined to stick with it, I can
provide only encouragement. Perhaps another responder on the NG can provide
some more detail.

--- Nick
 
Back
Top