[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XMLHTTP Timeout and ServerXMLHTTP receiving javascript error

Posted on 2009-02-11
8
Medium Priority
?
5,835 Views
Last Modified: 2012-05-06
Ok guys and gals here is my problem.

I am trying to send 2 POST and 1 GET to a remote server via my .vbs file script from my Windows 2003 server.  I know that I should be using the ServerXMLHTTP version but I can not get it to work properly and the XMLHTTP version just timesout.  When I use the XMLHTTP version it timesout on the line below.

objXMLHTTP3.Open "GET", "http://***.*********.com/lbs/AccessReport?Style=CSV&SID=" & strSID, false
objXMLHTTP3.Send  

When I use the ServerXMLHTTP version the remote server never let's me past the first POST.  I receive the following error from the remote server.
ERROR: Your browser's JavaScript capability seems to be disabled.
* So this never let's me past the login page.  :(

Below I have included the code that is requesting the 2 POST and 1 GET.  I have x'ed out the domain for privacy.  There may also be some variables that are not declared in the code provided but the are named elsewhere in the code.


Set objXMLHTTP = CreateObject("Msxml2.XMLHTTP.6.0")
 ' timeouts: resolve, connect, send, receive - in milliseconds
'objXMLHTTP.setTimeouts 10000, 60000, 30000, 30000
 
' Login
objXMLHTTP.Open "POST", "http://***.********.com/lbs/OnLogin", False
objXMLHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
objXMLHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
objXMLHTTP.Send "irtUserName=" & strUsername & "&irtUserPassword=" & strPassword
 
' Pause until page is ready
While objXMLHTTP.status <> 200 And objXMLHTTP.readyState <> 4
    objXMLHTTP.waitForResponse 1000 
Wend
Set objXMLHTTP = Nothing
 
' Set Permisson
Set objXMLHTTP2 = CreateObject("Msxml2.XMLHTTP.6.0")
objXMLHTTP2.Open "POST", "http://***.**********.com/lbs/OnSelectPermission", False
objXMLHTTP2.setRequestHeader "Referer", "http://***.**********.com/lbs/OnLogin" 
objXMLHTTP2.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
objXMLHTTP2.setRequestHeader "Host", "************.com"
objXMLHTTP2.setRequestHeader "Connection", "Keep-Alive" 
objXMLHTTP2.setRequestHeader "Cache-Control", "no-cache"
objXMLHTTP2.setRequestHeader "Cookie", "x=y" 
objXMLHTTP2.Send "irsPermissionID=" & "AG" & strAgentID & "*AGENT"
 
' Pause until page is ready
While objXMLHTTP2.status <> 200 And objXMLHTTP2.readyState <> 4
    objXMLHTTP2.waitForResponse 1000 
Wend
Set objXMLHTTP2 = Nothing
 
' Get CSV File 
Set objXMLHTTP3 = CreateObject("Msxml2.XMLHTTP.6.0")
objXMLHTTP3.Open "GET", "http://***.**********.com/lbs/AccessReport?Style=CSV&SID=" & strSentriLock_SID, false 
objXMLHTTP3.Send  
 
' Pause until page is ready
While objXMLHTTP3.status <> 200 And objXMLHTTP3.readyState <> 4
    objXMLHTTP3.waitForResponse 1000 
Wend
 
CSV_Text = objXMLHTTP3.responseText
Set objXMLHTTP3 = Nothing

Open in new window

0
Comment
Question by:TSPatrick
  • 4
  • 3
8 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 23623679
> ERROR: Your browser's JavaScript capability seems to be disabled.

Have you tried visiting the site with your browser and with javascript disabled? Did you find anyway to login?
0
 

Author Comment

by:TSPatrick
ID: 23624246
Should I try this from the browser on the server?
0
 
LVL 28

Expert Comment

by:sybe
ID: 23624416
It does not matter. It seems clear that the site you want to visit with the ServerXMLHTTP requires javascript to log in. Because ServerXMLHTTP does not support javascript, you are faced with a problem. Maybe you can work around it if the site lets you login without javascript. So my suggestion is just that: try to login on the site with a browser with javascript disabled.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TSPatrick
ID: 23624551
OK. I visit the site from my server with javascript disabled and was able to successfully login.  Wierd.  Becasue the file that is downlloaded with GET request is the login page and the javascript error.  Not sure what to do now.  Any ideas?
0
 
LVL 28

Expert Comment

by:sybe
ID: 23624673
Somewhere along the line you should have seen this error in your browser:
"ERROR: Your browser's JavaScript capability seems to be disabled. "

If not, maybe the browser responded to a metatag redirect.
But what you need to do is find the "action" of the login form, because that is where the username/password are send to. Also make sure that you know if it is POST or GET.

Also, and this is important, if you need to get behind a login with ServerXMLHTTP, then it is essential that you use the same ServerXMLHTTP object for login and then for getting to the other pages. The way you are doing it in your code (each time with a new object) is like logging, closing your browser and then expect to still be logged in after restarting the browser.


0
 

Author Comment

by:TSPatrick
ID: 23624806
I have logged in successfully with just XMLHTTP but it occasionally hangs un the GET request (Downloading a CSV file) but when I use the ServerXMLHTTP it send me back the content of the login page with the javascript error.
0
 
LVL 9

Expert Comment

by:AsishRaj
ID: 23628253
below is something that i implemented some time ago.

Customise it the way you want

 hope it helps
Function getField(strXPath, objDoc)
	Dim objNode
	Set objNode = objDoc.documentElement.selectSingleNode(strXPath)
 
	On Error Resume Next
	'clear the Err object
	Err.Clear
	'The following statement might cause an exception
	getField = objNode.Text
 
	'Check if an exception was raised
	If Err.Number >  0 then
	getField = ""
	End If
 
End Function
 
Sub connect()
'declaration	
	
	pxPayUrl    = "URL"
	pxPayUser  = "ID"
	pxPayKey = "Password"
 
 
	xmlRequest = "<ProcessResponse>" &_
	"<PxPayUserId>" & pxPayUser & "</PxPayUserId>" &_
	"<PxPayKey>" & pxPayKey & "</PxPayKey>" &_
	"<Response>" & result & "</Response>" &_
	"</ProcessResponse>"
 
 
	Set objSrvHTTP = server.Createobject("MSXML2.ServerXMLHTTP")
 
	objSrvHTTP.open "POST",pxPayUrl,False
	objSrvHTTP.send xmlRequest
	strReturn = objSrvHTTP.responseText
	
	Set xmlDoc = server.CreateObject ("Msxml2.FreeThreadedDOMDocument.3.0")
	xmlDoc.async = false
	xmlDoc.loadXML(strReturn)
	
'extracting codes should go here	
	
End Sub

Open in new window

0
 

Accepted Solution

by:
TSPatrick earned 0 total points
ID: 23632683
OK, nothing is working. It hangs (timesout) up on the following line.

objXMLHTTP.Open "GET", "http://***.*******.com/lbs/AccessReport?Style=CSV&SID=" & strSID, false
objXMLHTTP.Send  

Below is the code.  Please help.
Set objXMLHTTP = CreateObject("Msxml2.SERVERXMLHTTP.6.0")
 ' timeouts: resolve, connect, send, receive - in milliseconds
'objXMLHTTP.setTimeouts 10000, 60000, 30000, 30000
 
 
' Login
objXMLHTTP.Open "POST", "http://***.*******.com/lbs/OnLogin", False
objXMLHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
objXMLHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" 
objXMLHTTP.Send "irtUserName=" & strUsername & "&irtUserPassword=" & strPassword
 
' Pause until page is ready
While objXMLHTTP.status <> 200 And objXMLHTTP.readyState <> 4
    objXMLHTTP.waitForResponse 1000 
Wend
If strAgentID <> "" Then
' Set Permisson
objXMLHTTP.Open "POST", "http://***.*******.com/lbs/OnSelectPermission", False
objXMLHTTP.setRequestHeader "Referer", "http://***.*******.com/lbs/OnLogin" 
objXMLHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705)"
objXMLHTTP.setRequestHeader "Host", "sentrilock.com"
objXMLHTTP.setRequestHeader "Connection", "Keep-Alive" 
objXMLHTTP.setRequestHeader "Cache-Control", "no-cache"
objXMLHTTP.setRequestHeader "Cookie", "x=y" 
objXMLHTTP.Send "irsPermissionID=" & "AG" & strAgentID & "*AGENT"
' Pause until page is ready
While objXMLHTTP.status <> 200 And objXMLHTTP.readyState <> 4
    objXMLHTTP.waitForResponse 1000 
Wend
End If
 
' Get CSV File 
objXMLHTTP.Open "GET", "http://***.*******.com/lbs/AccessReport?Style=CSV&SID=" & strSID, false 
objXMLHTTP.Send  
 
' Pause until page is ready
While objXMLHTTP.status <> 200 And objXMLHTTP.readyState <> 4
    objXMLHTTP.waitForResponse 1000 
Wend
CSV_Text = objXMLHTTP.responseText
Set objXMLHTTP = Nothing

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Relic: Our company recently started researching several products to figure out what were the best ways for us to increase our web page speed and to quickly identify performance problems that we may be having. One of the products we evaluated wa…
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question