0

我正在使用 Visual Studio 2012 尝试将 GZip 压缩添加到来自 Silverlight 5 应用程序的 WCF请求。我还将 Fiddler2 与 WCF Binary 插件一起使用来检查消息的标题和正文(例如 Content-Type)。

我可以成功地将compressionFormat="GZip"属性添加到WinForms App.Config 文件中,这会导致发送Binary/GZipped 请求消息...

<?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 支持?

TIA

克雷格

4

1 回答 1

0

compressionFormat="GZip" is Working fine for me. Most of the time, problems with WCF/SL comes from configuration mismatch between Server and client. (I had spend hours with a server configured in customBinding / binaryEncoding and a client configured in basicHttpBinding)

compressionFormat="GZip" have to be set on the Server side in the web.config. Then you have to create ServiceReference on the Silverlight5 side, and that's all. There is no visible reference to compression in the ServiceReferences.ClientConfig file. All is done server side, and as I have have understood (i can make mistake), it's the browser who handle native gzip decompression, before passing message to the SL plugin.

PS : Inspect the wire with Fiddler to see the compression at work (it's really amazing).

于 2013-08-29T18:49:04.763 回答