Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
Recently I was working with some SQL Server SOAP webservices that another developer had written a while back. On reviewing the code it quickly became apparent that a particular webservice call was returning way too much data.
To make my case as to why this needed to be changed I decided to find an average returned record size and how big the data transfer was for it.
<!--- Get some data from the soap webservice --->
<cfinvoke webservice="webserviceName" method="someMethod" returnVariable="resultSet">
<!--- Some arguments --->
<!--- Get the data xml from the resultset --->
<cfset aDataset = resultSet.getSqlRowSet().get_any() />
<cfset xmlData = xmlParse(aDataset) />
<!--- Convert the data xml to a string --->
<cfset thestring = toString(xmlData)>
<!--- Convert character count to bytes --->
<cfset bytesLen = len(thestring) * 8>
<!--- Convert bytes to kilobytes --->
<cfset kbytesLen = bytesLen/1024>
<!--- Convert kilobytes to megabytes --->
<cfset mbytesLen = kbytesLen/1024>
I know its pretty simple code but it did its job and proved that the current webservices needed to be reworked so maybe it will help out someone else in a similar position in the future.