Jump to content
Gold Sponsor: Data-Way IT-Consulting, Austria

  • LaunchHTTPRequest

    LaunchHTTPRequest

    VBScript   → Lua

     

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

    Please see the Introduction chapter for some usage instructions.

     

    '-------------------------------------------------------------------
    ' 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
    
        Dim HTTP_REQ
        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
        HTTP_REQ.send
    
        If Err <> 0 Then
            PBXScript.OutputTrace "Error sending http request (" & Hex(Err) & ")"
            PBXScript.OutputTrace Err.Description
            Err.Clear
        Else
            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

     

    This function makes use of the Server Script API function PBXScript.OutputTrace to write trace information into the SwyxServer trace file.

     

    Another version of this function which makes use of the PBXScript.WebRequest object (which was introduced with SwyxWare 12.40) to perform the web request can be found in the LaunchHTTPRequestEx function.

     

    This function was initially posted into this forum topic.
     

     


    Tom Wellige
     Share


     Share




    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    Add a comment...

    ×   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.