Results 1 to 2 of 2

Thread: Call a service ("GET") via .vbs

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2015
    Posts
    12

    Call a service ("GET") via .vbs

    Hi all, I have a laptop with windows 32bit xp and I want to call a web service using a .vbs script, let it be https://www.testws.gr/sendMessages

    I tried the following version

    Code:
    Dim xmlhttp, myurl
    myurl = "https://www.testws.gr/sendMessages"
    
    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")  'Also tried "MSXML2.XMLHTTP" , "MSXML2.ServerXMLHTTP"
    xmlhttp.Open "GET", myurl, False
    xmlhttp.Send ""
    'MsgBox(xmlhttp.responseText)
    But I got errors as follow :

    Microsoft.XMLHTTP
    Error : System Error -2146697208
    Code : 800C0008
    Source : msxml3.ddl

    MSXML2.XMLHTTP
    Error : System Error -2146697208
    Code : 800C0008
    Source : msxml3.ddl

    MSXML2.ServerXMLHTTP
    Error : The message received was unexpected or badly formatted.
    Code : 80090326
    Source : msxml3.ddl

    When I open the browser and clicked url the service responses to me with a format like Number1/Number2
    such as 2/4.

    So, I decided to create a shell for opening chrome , a shell for waiting and a shell for closing chrome browsers.

    Code:
    function readFromRegistry (strRegistryKey, strDefault)
        Dim WSHShell, value
        On Error Resume Next
        Set WSHShell = CreateObject ("WScript.Shell")
        value = WSHShell.RegRead (strRegistryKey)
        if err.number <> 0 then
            readFromRegistry= strDefault
        else
            readFromRegistry=value
        end if
        set WSHShell = nothing
    end function
    
    function OpenWithChrome(strURL)
        Dim strChrome
        Dim WShellChrome
        strChrome = readFromRegistry ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe\Path", "") 
        if (strChrome = "") then
            strChrome = "Chrome.exe"
        else
            strChrome = strChrome & "\Chrome.exe"
        end if
        Set WShellChrome = CreateObject("WScript.Shell")
        strChrome = """" & strChrome & """" & " " & strURL
        WShellChrome.Run strChrome, 1, false
    end function
    
    function MySleep(milliseconds)
      set WScriptShell = CreateObject("WScript.Shell")
      WScriptShell.Run "Sleep -m " & milliseconds, 0, true
    end Function
    
    function closeChrome
      Set oShell = WScript.CreateObject ("WScript.Shell")
      oShell.Run "taskkill /f /t /im chrome.exe", 0, True
    end Function
    
    OpenWithChrome  "https://www.testws.gr/sendMessages"
    MySleep 60000  '60 secs
    closeChrome
    The above works as expected.
    The problem I have is the following :
    I would like to close after tab is completed loaded (without using miliseconds for waiting) and only the tab that is opened to be closed (not all the chromes windows)

    Moreover is there any way to get the response ?

    Thanks in advance for your help

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Call a service ("GET") via .vbs

    Find curl version with openssl support for TLS 1.2 + 1.3 that works on XP and then use shellexec to call it and access the web service.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width