Thursday, September 11, 2008

VB6 & REST

I want to call a REST service from my VB6 Macro. This page describes how to do this using IE 6 COM objects, instead of needing to install the MS SOAP Toolkit (if it is still available)

It will probably also work for IE 7 since the difference between the two is small. Anyway something to verify.


In case the original page gets lost:

' Create objects to DOMDocument and XMLHTTP
Set objDom = CreateObject("MSXML2.DOMDocument")
Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")

' Load XML
objDom.async = False
objDom.loadXML XmlBody

objXmlHttp.open "POST", AsmxUrl, False

objXmlHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXmlHttp.setRequestHeader "SOAPAction", SoapActionUrl

objXmlHttp.send objDom.xml

strRet = objXmlHttp.responseText

Set objXmlHttp = Nothing

' strRet contains result

No comments: