ADO.NET 数据服务的数据压缩

发布于 2024-08-10 12:58:09 字数 126 浏览 2 评论 0原文

我有一个由 .NET 应用程序(不是 IIS)公开的 ADO.NET 数据服务,该服务由 .NET 客户端应用程序使用。对此数据服务的某些调用会返回大量数据。

我想压缩传输中的 XML 数据以减少负载并提高性能。这可能吗?

I have an ADO.NET data service exposed by a .NET app (not IIS) which is consumed by a .NET client app. Some calls to this data service return large amounts of data.

I'd like to compress the XML data on the wire to reduce payload and improve performance. Is this possible?

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

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

发布评论

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

评论(2

最丧也最甜 2024-08-17 12:58:09

我假设您在 .NET“应用程序”中使用 WCF 进行托管 ?如果是这样,您需要编写一些自定义 MessageEncoder 实现,因为 WCF 没有提供开箱即用的功能。幸运的是,SDK 中有一个示例可供您使用。

我实际上刚刚意识到这只是两个步骤中的第一步,具体取决于您的客户是否也是 WCF?虽然这会对消息进行编码,但它会要求您的客户端使用类似配置的解码器,因为该实现将不会设置指示编码已发生为“纯”HTTP 所必需的 HTTP 标头客户。因此,如果另一端不是 WCF 客户端,除了对消息本身进行编码之外,您还需要使用 WebOperationContext 来应用适当的 Content-Encoding: gzip 标题。不幸的是,您无法在 MessageEncoder 实现本身中执行此操作,因为在该过程中为时已晚,因为当 MessageEncoder 被要求将消息内容写入消息帧时,在此如果 HTTP 标头已经被写入。因此,您还需要其他行为,其形式为 IOperationBehavior,应用于相应设置标头的操作。

I assume you're hosting using WCF in your .NET "app"? If so, you would need write some custom MessageEncoder implementation because WCF does not provide this out of the box. Luckily there is a sample in the SDK that you can use.

I actually just realized that this is only step one of two depending on whether or not your client is also WCF? While this will encode the message, it would require that your client be using a similarly configured decoder because that implementation will not set the HTTP headers that are necessary to signal that encoding has occurred to a "pure" HTTP client. So, if it's not a WCF client on the other side, in addition to encoding the message itself, you would need to use the WebOperationContext to apply the appropriate Content-Encoding: gzip header. Unfortunately you cannot do this within the MessageEncoder implementation itself because it's too late in the process because by the time the MessageEncoder is asked to write the message contents the message frame, in this case the HTTP headers, has already been written. So, you would also need additional behavior, in the form of an IOperationBehavior, applied to your operations that sets the headers accordingly.

骷髅 2024-08-17 12:58:09

您可以使用 GZipStream 来压缩和解压缩它。

You can use GZipStream to compress and decompress it.

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