• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6179
  • Last Modified:

XMLHTTP Timeout and ServerXMLHTTP receiving javascript error

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
TSPatrick
Asked:
TSPatrick
  • 4
  • 3
1 Solution
 
sybeCommented:
> 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
 
TSPatrickAuthor Commented:
Should I try this from the browser on the server?
0
 
sybeCommented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
TSPatrickAuthor Commented:
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
 
sybeCommented:
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
 
TSPatrickAuthor Commented:
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
 
AsishRajCommented:
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
 
TSPatrickAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now