简体   繁体   中英

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

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?

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM