序列化和编码有什么区别?
据我所知:
"序列化定义了.NET对象如何映射到XML,而编码定义了XML如何写入字节流。"
这个理解正确吗?
序列化和编码有什么区别?
据我所知:
"序列化定义了.NET对象如何映射到XML,而编码定义了XML如何写入字节流。"
这个理解正确吗?
是的。在客户端和服务器之间传输消息时,我们需要使用序列化将CLR类型转换为基于标准的XML。
WCF将序列化定义为将对象图转换为XML信息集(XML Infoset)的过程。
1. The XML Infoset is the data model WCF uses internally to represent a message.
2. The XML Infoset is the data model for representing an XML document.
编码(Encoding)用于描述将WCF消息转换为字节数组的过程。这样做是为了使消息可以通过传输协议发送。
以下是一个好的解释及示例:http://msdn.microsoft.com/en-us/magazine/cc163569.aspx#S1