How to change Wcf to use a different serializer?

前端 未结 3 1380
青春惊慌失措
青春惊慌失措 2021-01-05 00:27

By default WCF use DataContractSerialization so if we can change it then my question is how to change it and when should we need which serialization on wcf ?

3条回答
  •  误落风尘
    2021-01-05 00:44

    The default choice of DataContractSerializer is good for most purpose. You can also use the DataContractJsonSerializer specially for REST type services and if the client expects Json content type. The other option is XmlSerializer for interoperability purpose if you need more control over the generated XML. DataContractSerializer is more efficient than XmlSerializer.

    In 3rd party options you can use protobuf-net from Google which is more efficient than DataContract Serializer.

提交回复
热议问题