Author: Steven Neiland

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[3]) />

<!--- 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>

      bytes: #bytesLen#<br/>
      kilobytes: #kbytesLen#<br/>
      megabytes: #mbytesLen#

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.

What Do You Think?

Reader Comments

Post a Comment

Comment Etiquette:

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain or appear to be advertisments, will not be published.
  • Comments that appear to be created for the purpose of linkbuilding to commercial sites will be removed.

We are all adults here so play nice.


Archives Blog Listing

Tag Listing

Learn CF In A Week


Fork me on GitHub