How to: Set the ProtectionLevel Property

来源:互联网 发布:js工厂方法 编辑:程序博客网 时间:2024/05/01 07:12

http://msdn.microsoft.com/en-us/library/aa347791.aspx

To sign all messages for a service

[ServiceContract(ProtectionLevel = ProtectionLevel.Sign)]public interface ICalculator

To sign all message parts for an operation

// Set the ProtectionLevel on the whole service to Sign.[ServiceContract(ProtectionLevel = ProtectionLevel.Sign)]public interface ICalculator{    // Set the ProtectionLevel on this operation to None.    [OperationContract(ProtectionLevel = ProtectionLevel.Sign)]    double Add(double a, double b);}

Protecting Fault Messages

public interface ICalculator{    // Set the ProtectionLevel on a FaultContractAttribute.    [OperationContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]    [FaultContract(        typeof(MathFault),        Action = @"http://localhost/Add",        Name = "AddFault",        Namespace = "http://contoso.com",        ProtectionLevel = ProtectionLevel.EncryptAndSign)]    double Add(double a, double b);}
Protecting Message Parts

[MessageContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]public class Company{    [MessageHeader(ProtectionLevel = ProtectionLevel.Sign)]    public string CompanyName;    [MessageBodyMember(ProtectionLevel = ProtectionLevel.EncryptAndSign)]    public string CompanyID;}






原创粉丝点击