What type of serialization does Wcf use behind the scenes?

I know there are 3 types of s serialization in .net:

Soap , Xml , Binary. 

Wcf instructed the DataContract attribute, which also serializes ... but through what ?

Binary - I don’t know.

So what mechanism ?

+8
wcf
source share
2 answers

This is the binding defined for this endpoint that defines the serialization mechanism. For example:

  • wsHttpBinding and wsHttpBinding use SOAP
  • netTcpBinding uses binary serialization
  • webHttpBinding can use XML, Json, ...

You can read more about the various built-in bindings and their properties in this article . Thanks to the extensibility of WCF, you could, of course, write your own custom bindings.

+15
source share

You mix two techniques together.

  • Serialization - how objects are converted to messages - we have XML and JSON formats available from the box ( DataContractSerializer , DataContractJsonSerializer , XmlSerializer )
  • Encoding - how the message is transmitted - we have three encoders out of the box
    • TextMessageEncoder - for SOAP messages sent as text, it also supports MTOM and POX (plain old XML) if the message version is set to None
    • BinaryMessageEncoder - for XML / SOAP messages transmitted as binary data
    • WebMessageEncoder - for XML and JSON messages in REST services

These functions are used by standard relationships. WCF supports as much serialization and coding as you want => you can create your own.

+15
source share

All Articles