Get the size of an XLANG message

Posted: April 21, 2008  |  Categories: BizTalk Uncategorized

Here’s a little snippet of code I use to get the size of an XLANG message in bytes. Very efficient and always correct, it loops through each message part and adds up each part’s Size property. This is useful for when you need to know the size of the message inside an orchestration.


 //Returns the sum of the size of the message parts
 public static int GetMessageSize(Microsoft.XLANGs.BaseTypes.XLANGMessage msg)
   int msgSize = 0;
     foreach (Microsoft.XLANGs.BaseTypes.XLANGPart xp in msg)
       msgSize += Convert.ToInt32(xp.GetPartProperty(typeof(Microsoft.XLANGs.BaseTypes.Size)));
   catch (Exception ex)
     System.Diagnostics.EventLog.WriteEntry("XMLUtils GetMessageSize",
     ex.Message, System.Diagnostics.EventLogEntryType.Error);
   return msgSize;

2 thoughts on “Get the size of an XLANG message”

  1. Sorry but that doesn’t work for me. When I use this piece of code with an XML message, I obtain the size of -1.

Comments are closed.

BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More

Manage and monitor serverless
components effortlessly

Learn More
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top