Jump to content
Tom Wellige

Function: LaunchHTTPRequest

Recommended Posts

This post is taken from the Swyx Forum Archive (2007-2014) and was originally posted 27.04.2010 by me


This function calls (launches) a given URL (http request) and returns True if the request returns without error.

To use the function within your call routing script just copy&paste it into the "Start" block and call it afterwards within an "Evaluate" block.


' LaunchHTTPRequest
' Launches given URL.
' Parameter:
'	sURL		complete url
' return value:
'	boolean		True  - request file processed
'				False - request file *not* processed
Function LaunchHTTPRequest(ByVal sURL)
	PBXScript.OutputTrace "------> LaunchHTTPRequest ( sURL = '" sURL & "' )"

	On Error Resume Next

	Dim bReturn
	bReturn = True

	Set HTTP_REQ = CreateObject("Msxml2.ServerXMLHTTP.3.0")

	Dim lResolve, lConnect, lSend, lReceive
	lResolve =  1 * 60 * 1000	' 1 minute (default: infinte)
	lConnect =  1 * 60 * 1000	' 1 minute (default)
	lSend    = 60 * 60 * 1000	' 1 hour   (default: 30 seconds)
	lReceive = 60 * 60 * 1000	' 1 hour   (default: 30 seconds)
	HTTP_REQ.setTimeouts lResolve, lConnect, lSend, lReceive

	Dim vBefore, vAfter, nDuration
	vBefore = Now
	HTTP_REQ.open "GET", sURL, False

	If Err <> 0 Then
		PBXScript.OutputTrace "Error sending http request (" & Hex(Err) & ")"
		PBXScript.OutputTrace Err.Description
		vAfter = Now
		nDuration = DateDiff("s", vBefore, vAfter)
		PBXScript.OutputTrace "HTTP Request returned after " & nDuration & " seconds"
		bReturn = True
	End If

	Set HTTP_REQ = Nothing

	LaunchHTTPRequest = bReturn

	PBXScript.OutputTrace "bReturn = " & bReturn
	PBXScript.OutputTrace "<------ LaunchHTTPRequest"
End Function


Share this post

Link to post
Share on other sites

Hello Tom,


do i have to install anything on my Windows server to use this script?

do i have to install this for it to work (https://support.microsoft.com/en-us/help/290761/frequently-asked-questions-about-serverxmlhttp)?


because this script wont work on my windows 12 server.


Best regards Jakob H

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.