I want to do a VBScript that invokes a method of a webservice and give a response depending the parameters of entry.
I have an example:
But the problem is that my web service does not show me the answer. Someone could tell me why?
Thanks,
Uris
I have an example:
Code:
' 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-[URL unfurl="true"]www-form-urlencoded"[/URL]
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 = "[URL unfurl="true"]http://ws.cdyne.com/NotifyWS/PhoneNotify.asmx"[/URL]
'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
wScript.echo "Message: El resutaldo es: " &ws.Response
set ws = nothing
But the problem is that my web service does not show me the answer. Someone could tell me why?
Thanks,
Uris