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.)
I am creating a new user-define binding aka custom binding. example of the class is :
public class MyCustomBinding : CustomBinding
and override a function BindingElementCollection:
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<TransactionFlowBindingElement>();
SymmetricSecurityBindingElement securityElement = wSHttpBindingElementCollection.Remove<SymmetricSecurityBindingElement>();
MessageEncodingBindingElement textElement = wSHttpBindingElementCollection.Remove<MessageEncodingBindingElement>();
HttpTransportBindingElement transportElement = wSHttpBindingElementCollection.Remove<HttpTransportBindingElement>();
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;
}
what i am trying to do is copy all setting from wshttpbinding, and add on gzip as the message encoder. Compress an encrypted data will lead to a bigger size of the original data size. 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.