Control the response of xmlHTTP

  • Thread starter Thread starter Samir Ibrahim
  • Start date Start date
S

Samir Ibrahim

Hi all

I had post a question in msdn forum about how to control or manage the
response from xmlhttp request, I did not got any answer maybe because
they consider it as "malicious code".

any way, I had developed a sms/voice sending software in vb.net, every
thing works fine except if there is weak internet or delay from the
server I am sending my request to it.

I am using Microsoft XML v4 my code look like this

Let suppose I am trying to send request to imdb.com (for testing)

Public _xmlHTTP As New MSXML2.XMLHTTP ' declared in a module

Dim strResult As String
_xmlHTTP.open("POST", "http://www.imdb.com/find?s=tt", False)
_xmlHTTP.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
Dim parameter = "AVATAR" ' Movie name
Dim _sendText = "&q=<movie_name>".Replace("<movie_name>",parameter)
Application.DoEvents()
' send the request and the server should give response
_xmlHTTP.send(_sendText) ' here is where i want to put control.
strResult = _xmlHTTP.responseText
MsgBox(strResult)
End If

I am sending sms messages to a group, that group may consist of 1
person, or 1000 person. I am doing that be looping, so if for example i
am sending the message to a group that has 50 person, and in my loop I
reach 30, and the server hang or did not response

my program behaviour is: wait until the server response so it proceed
with the next send

what I want : giving the server 1 sec, if not response came, skip it and
send the next.

Can that be done?

TIA

Samir Ibrahim
 
Hi all

I had post a question in msdn forum about how to control or manage the
response from xmlhttp request, I did not got any answer maybe because
they consider it as "malicious code".

any way, I had developed a sms/voice sending software in vb.net, every
thing works fine except if there is weak internet or delay from the
server I am sending my request to it.

I am using Microsoft XML v4 my code look like this

Let suppose I am trying to send request to imdb.com (for testing)

Public _xmlHTTP As New MSXML2.XMLHTTP ' declared in a module

Dim strResult As String
_xmlHTTP.open("POST", "http://www.imdb.com/find?s=tt", False)
_xmlHTTP.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
Dim parameter = "AVATAR" ' Movie name
Dim _sendText = "&q=<movie_name>".Replace("<movie_name>",parameter)
Application.DoEvents()
' send the request and the server should give response
_xmlHTTP.send(_sendText) ' here is where i want to put control.
strResult = _xmlHTTP.responseText
MsgBox(strResult)
End If

I am sending sms messages to a group, that group may consist of 1
person, or 1000 person. I am doing that be looping, so if for example i
am sending the message to a group that has 50 person, and in my loop I
reach 30, and the server hang or did not response

my program behaviour is: wait until the server response so it proceed
with the next send

what I want : giving the server 1 sec, if not response came, skip it and
send the next.

Can that be done?

TIA

Samir Ibrahim

I suspect you did not get an answer before, as the question has more to
do with xmlhttp within msxml2 than it does with VB.Net.

Look at this page as an example of what you seem to be wanting to do:
http://msdn.microsoft.com/en-us/library/ms765535(VS.85).aspx.
 
Hi Mike,

Thank you for your guidance, actually I looked every where except the
xmlhttp itself.

I don't blame the msdn people, actually after re-read my own post, I
imagine a person who is trying to hack s site with brute-force :)

I will look to what you have posted, and it seem the answer the is there.

Thank you.

Samir Ibrahim
 
Just for the record.

I found the solution which work well(at my case) by using WebRequest
instead of xmlhttp

Dim myWebRequest As WebRequest = WebRequest.Create(url)
myWebRequest.Timeout = 1000

Thank you Mike for the hint about "Timeout"

Samir Ibrahim
 
Back
Top