The request.AutomaticDecompression property is on HttpWebRequest object.
I am not sure if you are using WCF OData Service. As per the Scott Hanselman's blog, this should work for WCF OData Service.
I guess the compression is not by default supported for BasciHttpBinding. The idea came from this blog.
I would create BehaviorExtensionElement, CompressionBehaviorSection as shown below.
public class MessageCompressionBehavior : IDispatchMessageInspector, IServiceBehavior, IClientMessageInspector
{
}
public class CompressionBehaviorExtensionElement :BehaviorExtensionElement
{
}
<extensions>
<behaviorExtensions>
<add name="compression" type="yournamespace.CompressionBehaviorExtensionElement, yourassembly, Version=...., Culture=neutral, PublicKeyToken=......"/>
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehavior>
<compression />
</serviceBehavior>
</behaviors>
Then apply this behavior on Basic Http Binding.
The IDispatchMessageInspector and IClientMessageInspector would compress / decompress the data depending on whether it is being sent or being received.
UPDATE: 29 / Jan / 2019
There is another way I found yesterday:
Step 1: If your service is IIS Hosted, you can enable dynamic Compression module.
Then add mime type for SOAP message in applicationHost.config as shown below:
<add mimeType="application/soap+xml" enabled="true" />
<add mimeType="application/soap+xml; charset=utf-8" enabled="true" />
<add mimeType="application/soap+xml; charset=ISO-8895-1" enabled="true" />
Step 2: Custom IWebRequestCreate
Once this is done, you will have to make the WCF send the "Accept Encoding" header with HTTP request. You can create custom IWebRequestCreate as shown below
public class CompressibleHttpRequestCreator : IWebRequestCreate
{
public CompressibleHttpRequestCreator()
{
}
WebRequest IWebRequestCreate.Create(Uri uri)
{
HttpWebRequest httpWebRequest =
Activator.CreateInstance(typeof(HttpWebRequest),
BindingFlags.CreateInstance | BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance,
null, new object[] { uri, null }, null) as HttpWebRequest;
if (httpWebRequest == null)
{
return null;
}
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip |
DecompressionMethods.Deflate;
return httpWebRequest;
}
}
Step 3: Configuration Change in your client's config
Then you can add below setting in your client's app.config or web.config:
<system.net>
<webRequestModules>
<remove prefix="http:"/>
<add prefix="http:" type="WcfHttpCompressionEnabler.CompressibleHttpRequestCreator, WcfHttpCompressionEnabler,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</webRequestModules>
</system.net>
The solution is explained at this blog. It also has a sample code at this link.
I hope this provides enough help on your issue.