WCF Xml vs Binary Serialization Pros and Cons
I know that if I use binary serialization with WCF I lose interopability.
If I'm willing to开发者_如何转开发 live with this I was wonderinf if there is an efficiency benefit in using binary over Xml.
And if there are any other pros and cons that I have not mentioned above
Yes - potentially a big one. XML serialized data is big compared with the binary equivalent. With binary, you lose readability and interoperability. You also lose the ability to host in IIS unless you are on Windows Server 2008 or Windows Vista or higher.
However, the performance gains if you are in a .NET to .NET scenario outweight these drawbacks in many situations.
If you don't need interoperability, yes, using binary serialization is much better (faster and more compact) than straight text serialization.
That's what makes the NetTcp binding so fast, compared to any of the Http bindings. But you can easily also do binary encoding over Http, if you control both ends of the wire.
See for instance Jeff Barnes' blog post on how to enable binary encoding over http, using just a custom binding configuration - no heavy-lift coding required! :-)
精彩评论