为 WCF 启用解压缩 - 服务?

发布于 2024-09-08 01:17:35 字数 163 浏览 4 评论 0原文

这对我来说是一个重大问题。早期,Web 服务客户端只需使用 EnableDecompression = true 就可以了,但是为什么微软不添加类似于 WCF 的东西呢?

我真的需要来自我的 WCF 服务的 gzip 压缩响应(它们需要是 http...遗留问题,像往常一样...你知道...)。

This is a major issue for me. In earlier times, web service clients could simply use EnableDecompression = true and all was good, but why did Microsoft not add something similar to WCF?

I really NEED gzip compressed responses from my WCF services (and they need to be http... legacy issues, as usual... you know...).

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

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

发布评论

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

评论(1

雨落星ぅ辰 2024-09-15 01:17:35

看看这个 博客文章 基本上最终建议:

结论

我现在放弃了这个,因为我们还需要
支持未设置的客户端
AcceptEncoding 标头所以我真的需要
读取 http 标头的能力
请求并将“上下文”值设置为
(不)压缩响应,我有
还没有找到如何做到这一点
多个并发请求。 我真的
推荐使用IIS http
压缩而不是尝试这样做
使用此处描述的 WCF 黑客攻击!

Codeplex 上还有一个 WCF 扩展项目,它有一个 WCF 压缩通道 - 也许这就是您正在寻找的。

最划算的方法是在 WCF 中使用 binaryMessageEncoding 而不是 textMessageEncoding(这是 HTTP 绑定的默认值)。这需要您 创建基于自定义 http 的绑定,并且会使您的服务与除也使用相同自定义绑定配置的 .NET 客户端之外的其他基于 http 的客户端不兼容。

Check out this blog post which basically ends up suggesting:

Conclusion

I now ditched this as we also need to
support clients that do not set the
AcceptEncoding header so I really need
the ability to read the http header in
request and set a "context" value to
(not) compress the response and I have
not found out yet how to do that per
multiple concurrent requests. I really
recommend to use the IIS http
compression and not try to do this
with WCF hacking as described here!

There's also a WCF Extensions project on Codeplex which has a WCF Compression Channel - maybe that'll be what you're looking for.

The most bang for the buck would be to use the binaryMessageEncoding in WCF instead of the textMessageEncoding (which is the default for HTTP bindings). That would require you to create a custom http based binding, and would render your service incompatible with other http-based clients other than .NET clients that are also using the same custom binding configuration.

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