WCF 分页结果&数据导出

发布于 2024-08-29 03:53:43 字数 314 浏览 6 评论 0原文

我参与过一个在数据层使用 WCF 服务的项目。目前,当网格需要数据时,将返回所有行,并将结果绑定到网格,并将数据集填充到会话变量中以进行分页/排序/重新绑定。我们已经遇到了最大消息大小问题,因此我认为是时候从获取和缓存转换为仅获取当前页面了。

从表面上看,这似乎很容易,但有一个小问题。用户可以随时导出整个结果集。这意味着出于网格查看的目的,获取当前页面是可以的,但是当他们想要导出时,我仍然需要调用所有数据。

这让我又回到了最大消息大小问题。对于这种类型的设置,推荐的方法是什么?

我们当前正在使用 wsHttpBinding...

感谢您的帮助。

I've walked into a project that is using a WCF service for the data tier. Currently, when data is needed for a grid, all rows are returned and the results are bound to a grid and the dataset is stuffed into a session variable for paging/sorting/rebinding. We've already hit a max message size problem, so I'm thinking it's time to convert from fetch and cache to fetch only the current page.

Face value this seems easy enough, but there's a small catch. The user is allowed to export the entire result set at any point. This means that for grid viewing purposes fetching the current page is fine, but when they want to do an export, I still need to make a call for all data.

This puts me back into the max message size issue. What is the recommended approach for this type of setup?

We are currently using the wsHttpBinding...

Thanks for any assistance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜妞爱困 2024-09-05 03:53:43

我认为对于大文件的推荐方法是使用 WCF 流式处理。我不确定您的情况的确切细节,但您可以将此作为起点:

http://msdn.microsoft.com/en-us/library/ms789010.aspx

I think the recommended approach for large files is to use WCF streaming. I'm not sure the exact details for your scenario, but you could take a look at this as a starting point:

http://msdn.microsoft.com/en-us/library/ms789010.aspx

谈场末日恋爱 2024-09-05 03:53:43

在您的情况下,我可能会做类似的事情

  • 使用“分页”GetData() 方法创建一个服务 - 您可以在其中指定页面索引和页面大小作为附加参数。这应该为您提供一个适合“常规”使用的漂亮干净的界面,并且不应达到 maxMessageSize 限制

  • 创建将发送所有数据的第二个服务(或方法) - 理想情况下,您可以将其捆绑到 ZIP 文件中或服务器上的某些内容,然后再发送。如果该 ZIP 文件仍然太大,您可能需要检查 WCF 流来处理大文件,正如 Andy 已经指出的那样

maxMessageSizeLimit 的存在有一个很好的理由:避免 WCF 服务刚刚获得的拒绝服务攻击大量信息涌入,导致其屈服。如果可以的话,请始终牢记这一点,不要只是将 maxMessageSize 提高到 2 GB - 它可能会反过来咬你:-)

I would probably do something like this in your case

  • create a service with a "paged" GetData() method - where you specify the page index and the page size as additional parameters. This should give you a nice clean interface for "regular" use, and that should not hit the maxMessageSize limits

  • create a second service (or method) that would send all data - ideally, you could bundle that up into a ZIP file or something on the server, before sending it. If that ZIP file is still too large, you might want to check out WCF streaming for handling large files, as Andy already pointed out

The maxMessageSizeLimit is in place for a good reason: to avoid Denial of Service attacks where a WCF service would just get flooded with large messages and thus brought to its knees. If you can, always try to keep that in mind and don't just jack up the maxMessageSize to 2 GB - it might come back to bite you :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文