.NET Framework Bookmark and Share   
 index > .NET Framework Networking and Communication > How do I get actual Message Size received/sent by WCF service??
 

How do I get actual Message Size received/sent by WCF service??

How do measure the actual size of message received/sent from/to channel by a WCF service.
I tried to put in trace but seems that does not give the actual message size.

I found this thread but seems this is complex to do in my situation since we have highly sophisticated code written around different kinds of message formats and encoding therein. http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/0e98f977-48f7-4617-8750-30a470c993dc/

My end goal is to be able to identify the change in size of message, if I gowith dataset vs a complex custom class. I am aware thatdataset is heavier to pass over the channel, however it is the dynamic nature of datathat left us to use datasets.

Dataset is dynamic based on how many ids we have, we have as many money valyes. Count of ID ranges from 1-20 in normal business situations.
Possible data structure if I replace dataset-

-------------------------------------------------
int?[] IDs

double?[] MoneyValue1

double?[] MoneyValue2

double?[] MoneyValue3

int Parameter1

string Parameter2

int Parameter3

------------------------------------------------

Thanks in advance.
Pritesh Ostwal
Pritesh Ostwal
I think trying to do this would be complex in my situation.
I took the middle path with help from a colleague and measured the data size with below statements, rest of it I did with timestamping with/without datasets-

You need to have Full trust on solution to run below code------------------------------------------------------

var file = new FileStream("test.bin", FileMode.Create);
var writer = XmlDictionaryWriter.CreateBinaryWriter(file);
var myObject = new MyClass();
myObject.MyProperty =
"asdfasdfasdfasdfasdfasdfjasdfjasdfasdfjasfjkasfasfasklf;jasdfkasf;las;fasklf;asdfkjlas;fsakl;fklasfjksa;f;kldfak;lsfdlasl;fskla;";
var serializer = new DataContractSerializer(typeof (MyClass));
serializer.WriteObject(writer, myObject);
file.Flush();
file.Close();
var size = new FileInfo("test.bin").Length;


MyClass
[DataContract]

public class MyClass{[DataMember]


-------------------------
Pritesh Ostwal

public string MyProperty {get; set; }}

Pritesh Ostwal
I think trying to do this would be complex in my situation.
I took the middle path with help from a colleague and measured the data size with below statements, rest of it I did with timestamping with/without datasets-

You need to have Full trust on solution to run below code------------------------------------------------------

var file = new FileStream("test.bin", FileMode.Create);
var writer = XmlDictionaryWriter.CreateBinaryWriter(file);
var myObject = new MyClass();
myObject.MyProperty =
"asdfasdfasdfasdfasdfasdfjasdfjasdfasdfjasfjkasfasfasklf;jasdfkasf;las;fasklf;asdfkjlas;fsakl;fklasfjksa;f;kldfak;lsfdlasl;fskla;";
var serializer = new DataContractSerializer(typeof (MyClass));
serializer.WriteObject(writer, myObject);
file.Flush();
file.Close();
var size = new FileInfo("test.bin").Length;


MyClass
[DataContract]

public class MyClass{[DataMember]


-------------------------
Pritesh Ostwal

public string MyProperty {get; set; }}

Pritesh Ostwal

You can use google to search for other answers

Custom Search

More Threads

• Unable to read data from transport connection
• The difference between IXpsDocument and XpsDocument
• Group Policy windows 2000
• Sending Email with System.Net.Mail.SmtpClient but with different message.Sender
• NullReferenceException when disposing MessageQueue
• An existing connection was forcibly closed by the remote host
• Trying to learn website design
• HttpListener in Console App and Web.Config
• file transfer between c# and python
• Remote Screen Viewing