VBScript
From CDYNE Wiki for Web Services
Consuming a Webservice with VBScript
We will use Phone Notify! Web Service to demonstrate the example
' VBScript source code class WebService public Url public Method public Response public Parameters public function execute() dim xmlhttp Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.open "POST", Url & "/" & Method, false xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xmlhttp.send Parameters.toString response = xmlhttp.responseText set xmlhttp = nothing end function Private Sub Class_Initialize() Set Parameters = new wsParameters End Sub Private Sub Class_Terminate() Set Parameters = Nothing End Sub End class class wsParameters public mCol public function toString() dim nItem dim buffer buffer = "" for nItem = 1 to Count buffer = buffer & Item(nItem).toString & "&" next if right(buffer,1)="&" then buffer = left(buffer,len(buffer)-1) end if toString = buffer end function public sub Clear set mcol = nothing Set mCol = CreateObject("Scripting.Dictionary") end sub public sub Add(pKey,pValue) dim newParameter set newParameter = new wsParameter newParameter.Key = pKey newParameter.Value = pValue mCol.Add mCol.count+1, newParameter set newParameter = nothing end sub public function Item(nKey) set Item=mCol.Item(nKey) end function public function ExistsXKey(pKey) dim nItem for nItem = 1 to mcol.count if mCol.Item(nItem).key = pKey then ExistsXKeyword = true exit for end if next end function public sub Remove(nKey) mCol.Remove(nKey) end sub public function Count() Count=mCol.count end function Private Sub Class_Initialize() Set mCol = CreateObject("Scripting.Dictionary") End Sub Private Sub Class_Terminate() Set mCol = Nothing End Sub end class class wsParameter public Key public Value public function toString() toString = Key & "=" & Value end function end class dim ws 'create web service object set ws = new webservice 'point it to CDYNE Phone Notify web service ws.Url = "http://ws.cdyne.com/NotifyWS/PhoneNotify.asmx" 'we want to call this method ws.Method = "NotifyPhoneEnglishBasic" 'fill parameters ws.Parameters.Add "PhoneNumberToDial", 7573440000 ' ws.Parameters.Add "TextToSay","Hey, this is a test message" ws.Parameters.Add "LicenseKey","0" ws.execute Debug.Write ws.Response set ws = nothing
Credits
The example is based on code from article
Class implementation for using webservices in ASP by asanoguera
