Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xmlhttp object

Status
Not open for further replies.

sodakotahusker

Programmer
Mar 15, 2001
601
I just learned a new trick today to download a pdf file from a web site. This involved using the XML parser object named xmlhttp. This worked wonderfully from my development machine. I ran this from a client and got an error that it was unable to connect to the server in my https URL. The only thing I can think of it is that some time of network/PC/Firewall limitation is preventing me from connecting. I was checking out the settings in IE and the TC/IP settings for the PC etc. but was unable to determine what is keeping me from reaching this server. Does anyone have a clue what could cause this? Thanks!!
 
Well not knowing what "Trick" you are talking about makes it hard to say what could be the problem with said fix.

Put up your code and let us see what might be the problem

Here is another trick for you

Code:
function GetPageByPOST(URL, Data) {
	// Create XMLHTTP Object (using older string)
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	// Build POST data
	// Send POST request to server
	xmlhttp.open("POST", URL, false);
	xmlhttp.send(Data);
	// Retrieve and display results of search
	var strText = xmlhttp.responseText;
	return strText;
}

What operating system is the client machine, what browser, what version, etc.
 
This is basically what I am doing. There is nothing wrong with my code. I'm not asking for help with the code. What I need to know is under what conditions one machine is able to connect to the URL specified and another is not - using the same executable.
I guess trick was not the correct term. I was using the Internet Transfer control previous to learning about this ability in the XML parser to retrieve a file.
 
you might have a problem with internet proxy...

try to run PROXYCFG.EXE from you dos prompt

Sergei
 
Thanks for the advice - but what will this tell me when I run it?
 
you can set your proxy with this utility as your XMLHttp object uses it.

or do a search on google for PROXYCFG.EXE and XMLHttp for more help
 
sodakotahusker - I just meant more information would have helped. Thats all. Just because code works on one machine doesn't mean it is correct. Not saying your code isn't. Its just not an assuption I make when there is a problem. I like to look at all the information to come up with information. When you ask a question if someone asks for clarification in an area you should in general provide it.

Also it wouldn't be bad for others to learn "Trick" you know. Knowledge is power. Give the power to the people I say.

Anyway microsoft's Howto is here
 
SemperFiDownUnda

you're right this is the url I used before to find about PROXYCFG utility.

sodakotahusker,

if this utility will solve your problem can you please let us know as I have a bit of code using XMLHttp object that doesn't work beyond local network and I suspect it's due to proxy configuration. I tried this utility and it didn't help me ... so I am intrested if it will help you

Sergei
 
From what I see this methodology will only work "server to server". My development PC is a WIndows 2000 Server. This application does not even work on my other Developer machine which is an XP Pro workstation. I might have to have the client call a DLL on an application server which retrieve the pdf and returns it to the client.
 
sodakotahusker

you talked yourself into it! as it was metion before litttle bit of code that gives you a problem would've helped to understnad what might be wrong but anyway it's your question and not mine

and xmlhttp object will work fine on Win NT/2000/XP server or workstation as long as it has ISS and MSXML parser installed

Sergei
 
What is ISS? Or did you mean IIS? My clients are not going to have IIS so it looks like I make the right choice. I am now going back to my original code which uses the WinInet API. That works fine on a regular workstation.
Thanks for the input, guys.
 
yes IIS not ISS ... my typo..

when you're asying your customers will not have IIS installed how's that ? you host your app on a server and then your client connects to your site and all XMLHttp stuff is happening there on a host and not on a client!

OK you might be using wrong MSXML object... there are two objects that can do what you're trying to do -> get html off the other site and one of these objects executes on Server and other on Client and then you need to have right version of MSXML parser installed on your client

anyway if you're using this object then you should be right as it's Server based:

Server.CreateObject("MSXML2.DOMDocument.3.0")
or
Server.CreateObject("MSXML2.DOMDocument.4.0")

I currently have simular problem my code works fine in Intranet or outside my dev invironment but I can't go from my dev box to internet and I know it's firewall issue... as you have a solution that works in simular scenario for you, would you please share with me what you're doing with WinInet API or at least direct me somewhere where I can get more info on this.

Thank you

Sergei
 
Here's a sample wininet function which returns a pdf file from a web server. You have to add the component to a form along with a textbox which you assign the URL to. The latter was to eliminate a problem . Good luck!

Private Function RetrievesampleReport(ByVal sPDFFileName As String) As Boolean

Dim sFileName As String
Dim sFilePath As String
Dim bKillFlag As Boolean
Dim sUser As String
Dim sPassword As String
Dim lFreeFile As Long

Dim sResponseFormat As String
Dim sUrl

On Error GoTo errHandler
Dim lMaxChunk As Long



sResponseFormat = "pdf" ' either "pdf" or "html"
' FORMAT THE URL

sUrl = " sUrl = sUrl & "?user=" & sUser & "&password=" & sPassword





Text1.Text = sUrl
' The assignment of string to text box and use of that text box in the function was made a necesary by an error that the url was malformed.
' I found an aricle on the Internet which explained how to circumvent that problem.

Inet1.Protocol = icHTTPS

Inet1.OpenURL Text1.Text, icByteArray

DoEvents



Inet1.Execute Text1.Text

lMaxChunk = 102400


lFreeFile = FreeFile()
If Dir(sPDFFileName) > " " Then
bKillFlag = True
Kill (sPDFFileName)
bKillFlag = False
End If
Open sPDFFileName For Binary Access Write Lock Read Write As #lFreeFile

Do

Erase aResult()
DoEvents

lChunkSize = lMaxChunk
aResult = Inet1.GetChunk(lChunkSize, icByteArray)


If LOF(lFreeFile) > 0 Then


Seek lFreeFile, LOF(lFreeFile) + 1

End If

Put lFreeFile, , aResult

DoEvents


Loop Until lChunkSize < lMaxChunk

Close #lFreeFile

Inet1.Cancel
RetrievesampleReport = True

Exit Function

errHandler:
DoEvents
' err 35764 indicates last request is still processing so resume
' set a threshold for retries so we don't get in an infinite loop
If bKillFlag = True Then
MsgBox &quot;The file could not be deleted. Looks like you did not close a previous acrobat reader window with a sample report in it!&quot;, vbInformation, &quot;Close that window and try again&quot;
RetrievesampleReport = False
Exit Function
End If
If Err = 35764 Then

Resume
End If

RetrievesampleReport = False
msgbox &quot;An error occurred - yedda yedda &quot; & error$


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top