在Silverlight中向WCF添加压缩的最简单的方法是什么? [英] What is the easiest way to add compression to WCF in Silverlight?

查看:108
本文介绍了在Silverlight中向WCF添加压缩的最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问WCF Web服务的silverlight 2 beta 2应用程序。因为这个,它目前只能使用basicHttp绑定。 webservice将返回相当大量的XML数据。从带宽使用的角度看,这似乎是相当浪费,因为响应,如果压缩,将小5的因素(我实际上将响应粘贴到一个txt文件并压缩它。



请求有Accept-Encoding:gzip,deflate - 有没有办法使WCF服务gzip(或以其他方式压缩)响应? >

我发现这个链接,但它确实似乎有些复杂的功能,应该处理开箱即用的IMHO。



OK - 起初我标记的解决方案使用System.IO.Compression作为答案,因为我永远不会似乎得到IIS7动态压缩工作。好了,结果是:


  1. IIS7上的动态压缩工作。这只是Nikhil的IE的Web开发人员助手插件没有显示它的工作。我的猜测是,因为SL将Web服务调用关闭到浏览器,浏览器处理它在封面下,Nikhil的工具从来没有看到压缩的响应。我能够通过使用Fiddler来确认这一点,它监视浏览器应用程序外部的流量。在fiddler中,响应实际上是gzip压缩的!


  2. System.IO.Compression解决方案的另一个问题是System.IO.Compression


所以从我的角度来看,在Silverlight中启用WCF压缩的EASIEST方法是在IIS7中启用动态压缩,并且不写任何代码。

解决方案

如果您使用IIS7, a href =http://blogs.iis.net/ksingla/archive/2006/06/13/changes-to-compression-in-iis7.aspx =nofollow noreferrer>压缩模块。这允许您为到您的服务器的HTTP请求配置压缩。


I have a silverlight 2 beta 2 application that accesses a WCF web service. Because of this, it currently can only use basicHttp binding. The webservice will return fairly large amounts of XML data. This seems fairly wasteful from a bandwidth usage standpoint as the response, if zipped, would be smaller by a factor of 5 (I actually pasted the response into a txt file and zipped it.).

The request does have the "Accept-Encoding: gzip, deflate" - Is there any way have the WCF service gzip (or otherwise compress) the response?

I did find this link but it sure seems a bit complex for functionality that should be handled out-of-the-box IMHO.

OK - at first I marked the solution using the System.IO.Compression as the answer as I could never "seem" to get the IIS7 dynamic compression to work. Well, as it turns out:

  1. Dynamic Compression on IIS7 was working al along. It is just that Nikhil's Web Developer Helper plugin for IE did not show it working. My guess is that since SL hands the web service call off to the browser, that the browser handles it "under the covers" and Nikhil's tool never sees the compressed response. I was able to confirm this by using Fiddler which monitors traffic external to the browser application. In fiddler, the response was, in fact, gzip compressed!!

  2. The other problem with the System.IO.Compression solution is that System.IO.Compression does not exist in the Silverlight CLR.

So from my perspective, the EASIEST way to enable WCF compression in Silverlight is to enable Dynamic Compression in IIS7 and write no code at all.

解决方案

If you are using IIS7, take a look at the Compression Module. This allows you to configure compression for HTTP requests to your server.

这篇关于在Silverlight中向WCF添加压缩的最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆