Determining The Size Of A SOAP Request With ColdFusion

Author: Steven Neiland
Published:

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 --->
</cfinvoke>

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

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

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.

Reader Comments

  • 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 advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing