Querying a web service using vbscript (virtual XML file)

There are lots of different ways people are building "web services" and "integration apis". This is one of many articles we have written to document that different types of vbscript code we have written for clients over the years.

In this example, we used vbscript to call an integration api by sending the integration api website an xml post. We don't literally create an XML file -- instead, we create an in memory a string that is formatted like an XML file, and then we send that "virtual XML" file to the integration web site.


'Declare variables

Dim xml

Dim url

Dim response

Dim ourorderid

Dim theirorderid

Dim shipdate

Dim tracking

xml = "<?xml version='1.0' encoding='utf-8' standalone='yes'?>" _

& "<update>" _

& "<orderid>" & theirorderid & "</orderid>" _

& "<status>Received</status>" _

& "<message></message>" _

& "<laborderid>" & ourorderid & "</laborderid>" _

& "</update>"

url = "https://api.integrationwebsite.com/roes/order/mycustomer"

set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

xmlhttp.open "POST", url, FALSE

xmlhttp.setRequestHeader "Content-type", "application/atom+xml"

xmlhttp.send xml

'Now handle the response

response = xmlhttp.responseText