简体   繁体   English

如何使用WCF传输大文件

[英]How to transfer large file using WCF

I need to transfer large Excel files over a WCF service. 我需要通过WCF服务传输大型Excel文件。 Our project requires generating some reports for the clients, and we use Excel to generate the reports. 我们的项目需要为客户生成一些报告,我们使用Excel生成报告。

Right now the project uses net.tcp binding, but we are considering switching over to http binding. 现在该项目使用net.tcp绑定,但我们正在考虑切换到http绑定。

I read another post on SO about transferring large images and the answers all suggested using streaming. 我读了另一篇关于传输大图像的帖子以及所有使用流媒体建议的答案。 However I'm wondering what the best approach would be considering its an Excel file. 但是我想知道最好的方法是考虑它的Excel文件。 The file sizes can sometimes approach ~10Mb. 文件大小有时可能接近〜10Mb。

Yes, streaming will work TCP or HTTP -- you should use it. 是的, 流式传输将使用TCP或HTTP - 您应该使用它。 Using streaming will remove the need to have large in-memory buffers holding the entire file at once. 使用流式传输将无需一次性保存整个文件的大型内存缓冲区。 This will increase scalability of your application. 这将提高应用程序的可伸缩性。

As JP says streaming is a good option- I would generally recommend going for that. 正如JP说流媒体是一个很好的选择 - 我通常会建议那样做。 The book "Essential Windows Communication Foundation" suggests that if you need reliable messaging, digital signatures or resuming after failure then another option is to manually chunk the data into smaller messages and then reconstitute them on the server. “基本Windows通信基础”一书表明,如果您需要可靠的消息传递,数字签名或故障后恢复,则另一种选择是手动将数据块化为较小的消息,然后在服务器上重新构建它们。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM