简体   繁体   English

如何将自定义对象序列化为流(WCF HttpBinding-TransferMode =流式)

[英]How to seralize custom objects into stream (WCF HttpBinding - TransferMode = Streamed)

I would like to know how to serialize custom objects into stream and send the stream via WCF Service. 我想知道如何将自定义对象序列化为流,并通过WCF服务发送流。 I am thinking to use XMLSerializer and serialize the objects into MemoryStream and pass it to Stream-type parameter of OperationContract method from client and when the request is received from the service, the Stream will be deserialized back to objects. 我正在考虑使用XMLSerializer并将对象序列化为MemoryStream,并将其从客户端传递给OperationContract方法的Stream-type参数,当从服务接收到请求时,Stream将反序列化回对象。

Your suggestion would be much appreciated! 您的建议将不胜感激!

The Streamed mode it should be used when you want to transfer big data. 当您要传输大数据时,应使用流模式。 The Streamed mode may add some overhead on transport layer. 流模式可能会增加传输层的一些开销。 Also you lose automatically serialization provided by WCF. 此外,您还会丢失WCF提供的自动序列化。

UPDATE XmlSerializer is not good for big data cause it use DOM. UPDATE XmlSerializer不适用于大数据,因为它使用DOM。 DOM parser loads entire xml content in memory and you will lose the benenfits of streaming (generating/consumming chunck by chunck of data). DOM解析器将整个xml内容加载到内存中,您将失去流式传输的好处(逐个数据生成/消耗大量数据)。 Binary or Custom Serialization should be your way. 二进制或自定义序列化应该是您的方式。 Also, don't forget to apply compression (more details http://social.msdn.microsoft.com/Forums/en-US/dataservices/thread/12557249-2775-44e4-bc39-49585cf15873/ ) 另外,不要忘记应用压缩(更多详细信息http://social.msdn.microsoft.com/Forums/zh-CN/dataservices/thread/12557249-2775-44e4-bc39-49585cf15873/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF HttpTransport:流式传输与缓冲的TransferMode - WCF HttpTransport: streamed vs buffered TransferMode 使用basichttpBinding和流的transfermode的WCF中出现错误请求 - error Bad Request in WCF using basichttpBinding with transfermode of streamed TransferMode = Streamed时发生TimeoutException - TimeoutException when TransferMode=Streamed NetTcpBinding()与TransferMode.Streamed - NetTcpBinding() with TransferMode.Streamed WCF:通过netTcpBinding通过TransferMode = Streamed将文件传输到服务器时,对客户端的响应延迟 - WCF: response to client delayed when transferring file to server with TransferMode=Streamed over netTcpBinding 具有TransferMode = Streamed的WCF REST客户端-记录整个(“原始”)http请求/响应 - WCF REST client with TransferMode=Streamed - logging entire (“raw”) http requests/responses 从wcf绑定transferMode从“Buffered”更改为“Streamed”是否被认为是客户端的重大变化? - Is changing from wcf binding transferMode from “Buffered” to “Streamed” considered a breaking change for the client? WCF HTTPBinding的局限性是什么? - What are the limitations of WCF HTTPBinding? TransferMode = Streamed时耗尽连接 - Running out of connections when TransferMode = Streamed WCF服务:transferMode:StreamingResponse不起作用 - WCF Service: transferMode: StreamingResponse is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM