0
votes

The request message must be protected. This is required by an operation of the contract ('IMyNumericService','http://tempuri.org/'). The protection must be provided by the binding ('BasicHttpBinding','http://tempuri.org/').

when i am trying to connect to the host where i have registered my service , i am getting the above exception. But Host was working ,when i try to connect from client app it was showing above exception

1
Looks like a binding mismatch. Please include your service configuration and your client configuration. - tomasr
Now it was working for WSHttpBinding ,but not for BasicHttpBinding - VinodKumar
So.... it's solved? If not, post your configurations so we can help you :) - tomasr
I got it, due to the security level my service is not allowed for BasicHttpBinding but it was allowing me to exchange through WSHttpBinding see this link remondo.net/configure-messageprotectionlevel-wcf msdn.microsoft.com/en-us/library/aa347692.aspx - VinodKumar
Any one got this doubt you can refer above links - VinodKumar

1 Answers

0
votes

On to client and service security in WCF. You can set the protection level of messages sent over the wire at the message, fault, operation and/or service level in WCF. There are three message ProtectionLevel property flavors to set as an attribute. This ensures that any endpoint used for the service will require this protection level as a minimum.

None Plain text traveling over the wire. Sign The message is digitally signed. Ensures no modification to the message. The message is still plain text. EncryptAndSign Before signing, the message is encrypted. Ensures no modification to the message and is scrambled. If, for instance, the EchoService is set a ProtectionLevel of EncryptAndSign on the ServiceContract level, an endpoint with BasicHttpBinding would fail to start up. This is because BasicHttpBinding doesn’t support this protection level by default (it can be enabled). [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)] public interface IEchoService { [OperationContract(IsOneWay = true)] void RegisterClient(Guid guid);

    [FaultContract(typeof(EchoFault))]
    [OperationContract]
    EchoMessage Echo(EchoMessage message);

    [OperationContract]
    List<EchoMessage> GetAllEchos();
}

Using this protection level with a BasicHttpBinding endpoint results in an exception on the host.

System.InvalidOperationException: The request message must be protected. This is required by an operation of the contract [..]. The protection must be provided by the binding [..].

However if we change the endpoint binding to, for instance, wsHttpBinding, the service runs fine. This is because WsHttpBinding supports the EncryptAndSign protection level by default.