You are here:
Microsoft SQL 2008 Database Server Microsoft SQL 2008 Database Server

XML RPC using ColdFusion and Microsoft.XMLHTTP COM Object

I had recently been reviewing some documentation on a web based API that was available as an XML RPC. At first I was wondering how to achieve this, but then adapted an ASP example provided into a nice neat ColdFusion implementation. For anybody else with a similar problem of invoking an XML RPC API, the code below will at least get you started and heading down the right track.

serviceurl = ‘;
serviceport = 99999;
serviceuser = ‘xxxxxxxx’;
servicepass = ‘????????’;
aData= ’123456789′;

strXML = “<?xml version=’1.0′ encoding=’utf-8′ ?>”;
strXML = strXML & ‘<rpc module=’test’ method=’Method Name’ version=’1.0′>”;
strXML = strXML & “<auth>”;
strXML = strXML & “<username>” & serviceuser & “</username>”;
strXML = strXML & “<password>” & servicepass & “</password>”;
strXML = strXML & “</auth>”;
strXML = strXML & “<cli datatype=’cli’>” & Trim(aData & “</cli>”;
strXML = strXML & “</rpc>”;
objHTTP = CreateObject(“com”,”Microsoft.XMLHTTP”);
objHTTP.Open(“POST”,serviceurl & ‘:’ & serviceport & ‘/’,false);

Once you have the response from the call, you can then use XmlParse() to transform the XML response into a working XML DOM for processing and for variable assignment.