Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Microsoft XMLHTTP object automation
Message
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
01106987
Message ID:
01107203
Views:
28
This message has been marked as the solution to the initial question of the thread.
XML Http is pretty limited and was really meant for a tool running on the server. As far as I can remember you can't set timeouts with XmlHttp, nor is it easy to configure proxy settings - it has to be done with special configuration files and registry tweaks.

You can use WinHttp though which does (but doesn't support Win9x/NT) and comes with recent versions of Windows. Below is basic code that demonstrates.

Or you can use wwIPStuff (http://www.west-wind.com/wwipstuff.asp) which does away with COM and runs on every Windows platform:
oHTTP = CREATE("wwHTTP")
oHTTP.nConnectTimeout = 5  && seconds
lcXML=oHttp.HttpGet("http://www.mysite.com/somedoc.xml")
+++ Rick ---
************************************************************************
* WinHttp 
****************************************
***  Function: Returns HTTP response from a URL as a string
***    Assume: Requires Windows 2000 or later! Must be installed
***            with installation (WinHttp is a COM object)
***      Pass: 
***    Return:
************************************************************************
LPARAMETERS lcUrl, lcPostBuffer, lcUsername, lcPassword, lcContentType, lnTimeout
LOCAL lcVerb, llResult, lcResponse

IF EMPTY(lnTimeout)
  lnTimeout = 20000
ELSE
  lnTimeout = lnTimeout * 1000
ENDIF

IF EMPTY(lcPostBuffer)
   lcPostBuffer = ""
ENDIF
IF EMPTY(lcUsername)
   lcUsername = ""
   lcPassword = ""
ENDIF
lcVerb = "GET"
IF !EMPTY(lcPostBuffer)
   lcVerb = "POST"
   IF EMPTY(lcContentType)
      *** try to sniff a little
      IF (lcPostBuffer = "<?")
         lcContentType = "text/xml"
      ELSE
         lcContentType = "application/x-www-form-urlencoded"
      ENDIF
   ENDIF
ENDIF

LOCAL loHttp as WinHttp.WinHttpRequest.5
loHttp = CREATEOBJECT("WinHttp.WinHttpRequest.5")

TRY 
   loHttp.Open(lcVerb,lcUrl,.f.)

   IF !EMPTY(lcContentType)
      loHttp.SetRequestHeader("Content-type",lcContentType)
   ENDIF
   
   loHttp.SetRequestHeader("User-Agent","West Wind WinHttp")
   loHttp.SetTimeouts(lnTimeout,lnTimeout,lnTimeout,lnTimeout)
   
   IF !EMPTY(lcUserName)
      loHttp.SetCredentials( lcUsername, lcPassword,0)
   ENDIF
   
   loHttp.Send(lcPostBuffer)
   
   lcResponse = STRCONV( loHTTP.ResponseBody,2 )
CATCH
   AERROR(laErrors)
   
   lcResponse =  "Error: " + laErrors[3]
   
ENDTRY


RETURN lcResponse
>Hi all,
>
>I'm extensely using synchrous xml http calls from within a typical fat-client application. Example:
>
>oXMLParser = CREATEOBJECT("Microsoft.XMLHTTP")
>oXMLParser.OPEN("get","http://www.mysite/myres.xml",.F.) && sync. call
>oXMLParser.SEND() && this line locks up
>
>The whole thing is now working fine in production. Performance is fine except in one situation, "when the Internet is not available". A situation that tends to occurs quite often at customers' premises.
>
>What happens then is the following: the .SEND() action locks the full process up until the "http timeout" is sent until an error is sent and caught by a VFP exception.
>
>Until then the application looks "locked up", frozen in an error state for definitely a time period which is too long.
>
>Any way to handle with that in a more graceful way without resorting to ASYNC calls? A safe API call that would check internet resource availabily beforehand for example?
>
>Francois
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform