Force WCF to use NetDataContractSerializer\DataContractSerializer
How can I tell a certain WCF Servi开发者_StackOverflow中文版ce to use DataContractSerializer or NetDataContractSerializer?
Suppose I succeed, will the proxy generated automatically identify it and use the correct one?
DataContractSerializer
is used by default. On the service side you can control used serializers with behaviors. By default you have available DataContractFormat
and XmlSerializerFormat
attributes for this. These attributes can be applied on service contract, service implementation or on operations. On client side svcutil will use data contract serialization if types description are serializable by DataContractSerializer
otherwise it will use XmlSerializer
.
NetDataContractSerializer
doesn't have behaviour prepared - you must create it yourselves. It is also not recognized by clients because when you use NetDataContractSerializer
you will share assemblies with types (data contracts, service contracts) with client so you can share behaviour as well and mark service contract with that behaviour directly.
精彩评论