Messages returned from a netTcpBinding WCF service are larger than those returned from an ASMX web service

72 views Asked by At

Basically, I've created a netTcpBinding WCF service with a method that returns a set of simple objects ranging from 500 to 50000 objects. These object contains some string, int and DateTime properties. I was trying to test the memory consumption after calling this method. I've noticed that when I perform the same test with the classic ASMX web service, the memory consumption is less in this case. What I understand is that messages in netTcpBinding WCF services are binary-encoded whereas they are XML-formatted in ASMX web services, so messages should be smaller in the former case. However, the messages returned from the netTcpBinding service are almost 2x the size of ASMX messages. Any idea why this is happening?

1

There are 1 answers

1
Andrew Leon On

My understanding is that ASMX is HTTP based only using the SOAP protocol to transfer data, whereas WCF has multiple binding and transport options.

TCP/IP operates as a streamed connection between the WebService and the object consuming the WebService. TCP/IP will re-transmit any lost packets (all connections will have a few packets lost) which in-turn could cause the overall transmitted data to be greater.

See: http://msdn.microsoft.com/en-us/library/ms733769(v=vs.110).aspx

The question really lies in how you are calculating memory loss. Are you using the GC class or measuring the total size of the request headers?