title: How to build a custom binding by having WSHttpBinding security and GZip compression?
body: <p>i am facing a problem here.
  I am doing a client/server project, which is WCF web service calling to get data.Due to huge data of transfering, i got to change my binding to custom binding programmatically(not by config file.)</p>
  
  <p>I am creating a new user-define binding aka custom binding.
  example of the class is :</p>
  
  <pre><code>public class MyCustomBinding : CustomBinding    
  </code></pre>
  
  <p>and override a function BindingElementCollection:</p>
  
  <pre><code>public override BindingElementCollection CreateBindingElements()
  {
     WSHttpBinding wSHttpBinding = new WSHttpBinding("RMSKeberosBinding"); //this is to load the configuration from app.config. because i want to copy the setting of wsHttpConfig to my custom binding.
  
     BindingElementCollection wSHttpBindingElementCollection = wSHttpBinding.CreateBindingElements();
  
     TransactionFlowBindingElement transactionFlowBindingElement = wSHttpBindingElementCollection.Remove&amp;lt;TransactionFlowBindingElement&amp;gt;();
     SymmetricSecurityBindingElement securityElement = wSHttpBindingElementCollection.Remove&amp;lt;SymmetricSecurityBindingElement&amp;gt;();
     MessageEncodingBindingElement textElement = wSHttpBindingElementCollection.Remove&amp;lt;MessageEncodingBindingElement&amp;gt;();
     HttpTransportBindingElement transportElement = wSHttpBindingElementCollection.Remove&amp;lt;HttpTransportBindingElement&amp;gt;();
  
     GZipMessageEncodingBindingElement gzipElement = new GZipMessageEncodingBindingElement(); // this is from microsoft sample. i want to add gzip as a compress to my message.
  
     BindingElementCollection newCol = new BindingElementCollection();
     newCol.Add(transactionFlowBindingElement);
     newCol.Add(securityElement);
     newCol.Add(gzipElement);
     newCo .Add(transElement);
     return newCol;
  }
  </code></pre>
  
  <p>what i am trying to do is copy all setting from wshttpbinding, and add on gzip as the message encoder.
  <strong>Compress an encrypted data will lead to a bigger size of the original data size.</strong>
  this is because the SymmetricSecurityBindingElement from WSHttpBinding did the encryption.
  How to do this in correct way? i want the security setting from wshttpbinding, and also the gzip to work.</p>