Silverlight中的WCF请求压缩
我正在使用Visual Studio 2012尝试将GZip压缩添加到来自Silverlight 5应用程序的WCF请求中。我还将Fiddler2与WCF二进制插件一起使用,以检查消息的标题和正文(例如,内容类型) 我可以成功地将compressionFormat=“GZip”属性添加到WinForms App.Config文件,从而发送二进制/GZip请求消息Silverlight中的WCF请求压缩,silverlight,request,gzip,Silverlight,Request,Gzip,我正在使用Visual Studio 2012尝试将GZip压缩添加到来自Silverlight 5应用程序的WCF请求中。我还将Fiddler2与WCF二进制插件一起使用,以检查消息的标题和正文(例如,内容类型) 我可以成功地将compressionFormat=“GZip”属性添加到WinForms App.Config文件,从而发送二进制/GZip请求消息 <?xml version="1.0" encoding="utf-8" ?> <configuration>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IService1">
<binaryMessageEncoding compressionFormat="GZip" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost/WcfService2/Service1.svc"
binding="customBinding" bindingConfiguration="CustomBinding_IService1"
contract="ServiceReference1.IService1" name="CustomBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
但我无法将相同的compressionFormat=“GZip”属性添加到Silverlight 5应用程序(仍然是VS2012)
有人能证实或否认这一点吗?有解决办法吗
我怀疑这是因为VS2012中的SL5仍在使用WCF 4.0。再说一次,有人能证实或否认吗?有人知道是否会向Silverlight添加WCF4.5支持吗
短暂性脑缺血发作
克雷格compressionFormat=“GZip”
对我来说很好。大多数情况下,WCF/SL的问题来自服务器和客户端之间的配置不匹配。(我花了数小时在customBinding/binaryEncoding中配置的服务器和basicHttpBinding中配置的客户端上)
必须在服务器端的web.config
中设置compressionFormat=“GZip”
。
然后您必须在Silverlight5端创建ServiceReference,仅此而已。servicerences.ClientConfig
文件中没有对压缩的可见引用。所有这些都是在服务器端完成的,正如我所理解的(我可能会犯错误),在将消息传递给SL插件之前,是浏览器处理本机gzip解压缩
PS:用Fiddler检查电线,看看工作时的压缩情况(真是太神奇了)