WebBrowser.Navigate failes to do POST request when run as NT service

   This is my code for uploading file using WebComponent:
    This code works fine when I run it as a standard EXE.
    However, when I made an NT service running under "Local System" account, this code stopped working.
    The call to Navigate is successfull, yet no data send with the POST request arrives on the server side. Essentially, my POST request becomes an HTTP GET request.
=========================================================

    Dim sWebServerResponse As String
    Dim PostData() As Byte, sPostData As String
    Dim vPostData As Variant
   
    UploadFile = False
           
     ' This is required when making an HTTP POST request by calling Navigate and passing URL-encoded PostData
    ' sPostData contains URL-encoded data from the file
    sPostData = UrlEncodeFile(sInFileName, sOutErrMsg)
   
    ' This is required when making an HTTP POST request by calling Navigate and passing URL-encoded PostData    
    PostData = StrConv(sPostData, vbFromUnicode)
    vPostData = PostData
   
    If WB.Busy Then
        WB.Stop
    End If
   
 lFlags = eNavNoHistory Or eNavNoReadFromCache
sHeaders = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
sInTargetFrame = ""
sURL = "http://localhost/FileUpload/FileUpload.asp?Database=XXX&UserId=ZZZ&Passwrod=YYY"
    ' Does not work when ivoked by NT service
    WB.Navigate sURL, lFlags , sInTargetFrame, vPostData, sInHeaders
    m_FileUploadDone = False    
    ' m_FileUploadDone is set by the event handler
    ' each VB form that has a WebBrowser control implements DocumentComplete
    Do While Not m_FileUploadDone
        If DateDiff("s", dtStart, Now) > dInTransferTimeout Then
            WB.Stop
            DoEvents
            m_FileUploadDone = True
            sOutErrMsg = "PROBLEM: Upload timed out."
            Exit Function
        End If
        DoEvents
    Loop
    sWebServerResponse = WB.Document.Body.innerHTML
UmkaAsked:
Who is Participating?
 
anthony_glenwrightConnect With a Mentor Commented:
If you don't need to support Windows 98 (which I'm guessing you don't), try the ServerXMLHTTP object.  You don't have to be using XML to use it, I have used it's baby brother (XMLHTTP) to download EXE files from a web server.  Is *is* inside MSXML though, so you need the MSXML parser (v4) from msdn.microsoft.com/xml

http://msdn.microsoft.com/library/en-us/xmlsdk/htm/xml_obj_iserverxmlhttprequest_7zlc.asp?frame=true

Your code will go something like this:
Dim intFile As Integer
Dim strPath As String
Dim xmlUpgradeFile As MSXML2.XMLHTTPServer

strPath = "http://somewhere.com/files/thing.xyz"

Set xmlUpgradeFile = New MSXML2.XMLHTTPServer
xmlUpgradeFile.open "GET", strPath, False, "", ""
       
xmlUpgradeFile.send
     
If xmlUpgradeFile.Status = 200 Then
  intFile = FreeFile
       
  strTemp = Space(255)
  GetTempPath Len(strTemp), strTemp
  strTemp = Split(strTemp, Chr$(0))(0)
       
  Open "C;\temp\"& Split(strPath, "/")(UBound(Split(strPath, "/"))) For Output As intFile
  Print #intFile, StrConv(xmlUpgradeFile.responseBody, vbUnicode)
  Close intFile
End if

The benefit (and the reason I'm suggesting it in your case) of the XMLHTTPServer object over the Webbrowser is that it was specifically written for server applications.
0
 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
anthony_glenwrightCommented:
<me too - listening, that is>

Is there any reason you are using the webbrowser instead of one of the lower-level APIs?  Search for WinInet on msdn.microsoft.com if you don't know what I mean...
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
UmkaAuthor Commented:
The reason to use WebBrowser :

To avoid any complex coding to take care of firewall issues
, proxy settings, etc.
It's all easily can be configured using WebBrowser component.
0
 
DanRollinsCommented:
Hi Umka,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept anthony_glenwright's comment(s) as an answer.

Umka, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
kodiakbearCommented:
Moving to the paq

kb
Experts Exchange Moderator
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.

All Courses

From novice to tech pro — start learning today.