Вопрос по silverlight, gzip, compression, wcf – Какой самый простой способ добавить сжатие к WCF в Silverlight?

24

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Я нашел этоссылка на сайтError: User Rate Limit Exceeded

Хорошо - сначала я пометил решение, используя System.IO.Compression в качестве ответа, поскольку я никогда не мог "показаться" заставить работать динамическое сжатие IIS7. Ну как получается

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!!

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

Поэтому, с моей точки зрения, самый простой способ включить сжатие WCF в Silverlight - это включить динамическое сжатие в IIS7 и вообще не писать код.

Error: User Rate Limit Exceeded Boppity Bop

Ваш Ответ

4   ответа
12

Error: User Rate Limit Exceeded caryden
10

Error: User Rate Limit Exceeded
11

public static class CompressedSerializer
{
    /// <summary>
    /// Decompresses the specified compressed data.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="compressedData">The compressed data.</param>
    /// <returns></returns>
    public static T Decompress<T>(byte[] compressedData) where T : class
    {
        T result = null;
        using (MemoryStream memory = new MemoryStream())
        {
            memory.Write(compressedData, 0, compressedData.Length);
            memory.Position = 0L;

            using (GZipStream zip= new GZipStream(memory, CompressionMode.Decompress, true))
            {
                zip.Flush();
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                result = formatter.Deserialize(zip) as T;
            }
        }

        return result;
    }

    /// <summary>
    /// Compresses the specified data.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="data">The data.</param>
    /// <returns></returns>
    public static byte[] Compress<T>(T data)
    {
        byte[] result = null;
        using (MemoryStream memory = new MemoryStream())
        {
            using (GZipStream zip= new GZipStream(memory, CompressionMode.Compress, true))
            {
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                formatter.Serialize(zip, data);
            }

            result = memory.ToArray();
        }

        return result;
    }
}

void ReceiveData(byte[] data);

3

applicationHost.config<httpCompression><dynamicTypes>

<add mimeType="application/soap+msbin1" enabled="true" />

NO_MATCHING_CONTENT_TYPEcomplete trace

Error: User Rate Limit Exceeded

Похожие вопросы