Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking a Web Service from VBScript

Status
Not open for further replies.

joannadarling

Programmer
May 20, 2008
5
US
I could use some help calling a web service from VBScript. I can't find any example that I've successfully been able to implement. I'm just trying to get a test web service to work, I just picked one from And I guess I really just have no idea what I'm doing. Are there any resources that can explain exactly what I need to do, or exactly which functions I have available to me, the steps I need to take, and what each step means?

Anything??

Thanks,
Joanna
 
hmm well are you running the vbscript from with in a .NET app or are you just running the vbscript stand alone? I am not sure if you can use a web service in a stand alone vbscript, unless you are starting and stoping the webservice that I know can be done. I at least haven't seen where you can call it from a stand alone script.
 
>I am not sure if you can use a web service in a stand alone vbscript,
Sure you can, I would say.
 
This is how you consume the ValidateZip service with HTTP POST.
[tt]
surl="[ignore][/ignore]"
srequest="ZipCode=40020"

'assumed msxml2 core service well installed
set oxmlhttp=createobject("msxml2.xmlhttp")
with oxmlhttp
.open "post",surl,false
.setRequestHeader "Content-Type", "application/x- .send srequest
end with

set oparser=createobject("msxml2.domdocument")
oparser.loadXML oxmlhttp.responseXML.documentElement.text

set oroot=oparser.documentElement

if oroot.getAttribute("code")=200 then
with oroot.getElementsByTagName("item")(0)
zipcode=.getAttribute("zip")
state=.getAttribute("state")
latitude=.getAttribute("latitude")
longitude=.getAttribute("longitude")
end with
wscript.echo zipcode & vbcrlf & state & vbcrlf & latitude & vbcrlf & longitude
else
wscript.echo "error occurred"
end if

set oroot=nothing
set oparser=nothing
set oxmlhttp=nothing
[/tt]
 
Really, that is interesting. I didn't realize vbscript had that capability, my bad. I was thinking it would really only used in a .Net app. That is definitly cool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top