public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {

            var proReq =
                bindingParameters.Remove<ChannelProtectionRequirements>();

            proReq = new ChannelProtectionRequirements();

            MessagePartSpecification unProtectedSpec = new MessagePartSpecification();
            MessagePartSpecification protectedSpec = new MessagePartSpecification(true);

            // I'm setting same protection level for all the actions.
            // You could specify different protection level per action, if required. 
            // Also note, I haven't implemented any support for custom SOAP headers.
            // However that can easily be added using the same mechansim.
            switch (level)
            {
                case ProtectionLevel.None:
                    proReq.OutgoingSignatureParts.AddParts(unProtectedSpec, "*");
                    proReq.IncomingSignatureParts.AddParts(unProtectedSpec, "*");

                    proReq.OutgoingEncryptionParts.AddParts(unProtectedSpec, "*");
                    proReq.IncomingEncryptionParts.AddParts(unProtectedSpec, "*");
                    break;
                case ProtectionLevel.Sign:
                    proReq.OutgoingSignatureParts.AddParts(protectedSpec, "*");
                    proReq.IncomingSignatureParts.AddParts(protectedSpec, "*");

                    proReq.OutgoingEncryptionParts.AddParts(unProtectedSpec, "*");
                    proReq.IncomingEncryptionParts.AddParts(unProtectedSpec, "*");
                    break;
                case ProtectionLevel.EncryptAndSign:
                    proReq.OutgoingSignatureParts.AddParts(protectedSpec, "*");
                    proReq.IncomingSignatureParts.AddParts(protectedSpec, "*");

                    proReq.OutgoingEncryptionParts.AddParts(protectedSpec, "*");
                    proReq.IncomingEncryptionParts.AddParts(protectedSpec, "*");
                    break;
            }
            // Add our protection requirement for this endpoint into the binding params.

            bindingParameters.Add(proReq);
        }