Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7667525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:07:35+00:00 2026-05-31T15:07:35+00:00

We have a data service provider that is providing us with Dynamic Compression on

  • 0

We have a data service provider that is providing us with Dynamic Compression on a WCF Data Services site. We need to make use of that compression because the raw data that we are pulling is more than 5Gb daily. Using gzip that will fall dramatically.

We have a client application which was created using the “Add service reference” wizard in Visual Studio 2010 which is based on the DataServiceContext class. I am able to specify the Accept: gzip, deflate header using the SendingRequest event, but how can I get the deserializer to decode the stream before it tries to parse the XML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:07:37+00:00Added an answer on May 31, 2026 at 3:07 pm

    I couldn’t figure out how to do this with the provided framework tools so I had to roll my own. First is the method that does the actual request that shows how to specify the header that requests gzip encoding and unzips the result.

      private static IEnumerable<dynamic> MakeHttpQuery(string uri)
      {
         var request = (HttpWebRequest)WebRequest.Create(new Uri(uri));
         request.Method = "GET";
         request.Accept = "application/json";
         request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip");
    
         try
         {
            var response = request.GetResponse();
            var contentEncoding = response.Headers[HttpResponseHeader.ContentEncoding];
            var responseStream = response.GetResponseStream();
    
            if (!string.IsNullOrEmpty(contentEncoding) && contentEncoding.Equals("gzip"))
            {
               responseStream = new GZipStream(responseStream, CompressionMode.Decompress);
            }
    
            var json = JsonObject.Parse(responseStream);
            var d = json["d"];
            if (!d.IsArray) return new JsonArray(new[] {d}).Values;
            else return ((JsonArray) d).Values;
         }
         catch (WebException webException)
         {
            log4net.LogManager.GetLogger(typeof(ProfileMediaDataInterface)).Error(webException);
            return new JsonArray(new JsonValue[] {}).Values;
         }
      }
    

    The DynamicJson library is an open-source library that I wrote a while ago which came in very handy here. You can very easily leave out the Accept: application/json header and then you will get back XML. In this case, something like linq-to-xml will also work, in very much the same way.

    Next the client code. This shows how to construct the URL to pass to the MakeHttpQuery method also what to do with the result.

      public static List<BenchmarkListSqr> GetBenchmarkListSqr(string currencyCode)
      {
         return 
            MakeHttpQuery(
               CreateDataService()
               .BenchmarkList
               .Where(bm => bm.Currency == currencyCode)
               .ToString())
            .Select(x => new BenchmarkListSqr(
               x.Currency, 
               x.AssetClass, 
               ToNullDateTime(x.AvailableFromDate), 
               x.ID, 
               ToNullDateTime(x.InceptionDate), 
               x.Name, 
               x.Region, 
               ToNullDecimal(x.ShareID)))
            .ToList();
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Data Service created using WCF that internally uses nHibernate. This WCF
I have a simple WCF Data Services service and I want to expose a
I have a WCF web-service and a Silverlight app displaying data from that service.
I have a working WCF Data Service built on a Linq2Sql data provider. Things
Possible Duplicate: Injecting data to a WCF service I have a WCF service that
We have a Data Access service in our SOA WCF system. This service is
I have a problem with my WCF Data Service, and this one is just
I have a Web Service written in .NET that provides data for an iPhone
I have a WCF data service hosted on a IIS server; I am using
Our team is evaluating using WCF Data Services (formerly ADO.NET Data Services), and have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.