FaultContractAttribute.ProtectionLevel 屬性

定義

指定 SOAP 錯誤從繫結要求的保護層級。

public:
 property System::Net::Security::ProtectionLevel ProtectionLevel { System::Net::Security::ProtectionLevel get(); void set(System::Net::Security::ProtectionLevel value); };
public System.Net.Security.ProtectionLevel ProtectionLevel { get; set; }
member this.ProtectionLevel : System.Net.Security.ProtectionLevel with get, set
Public Property ProtectionLevel As ProtectionLevel

屬性值

其中一個 ProtectionLevel 值。 預設值為 None

備註

您可以使用 FaultDescription.ProtectionLevel 屬性來指定傳送 SOAP 錯誤時,繫結必須加密、簽署,或兩者都進行的程度。 強烈建議在合約上,就明確指定作業錯誤的安全保護層級需求。 預設保護層級為 ProtectionLevel.None ,這表示您定義的 SOAP 錯誤訊息不需要加密或數位簽章 (,但系結在設定為) 時,可能會提供此支援。 如果錯誤訊息含有敏感性或可能導致安全性問題的資訊,強烈建議 ProtectionLevel 將 屬性設定為 ProtectionLevel.EncryptAndSign 。 如需安全性問題的詳細資訊,請參閱 瞭解保護層級

執行階段的保護行為,是各個保護層級屬性的組合,這些屬性具有階層式結構。 除非針對較窄的範圍明確設定不同的值,否則,設定最外層的值會建立所有較窄範圍的預設值。 在此情況下,外部值仍為所有較窄範圍的預設值 (特別設定的範圍除外)。

例如,如果 ServiceContractAttribute.ProtectionLevel 設為 ProtectionLevel.EncryptAndSign ,而且沒有其他較窄的範圍具有保護層級設定,則作業合約中的所有訊息都會加密並簽署,包括錯誤訊息。 不過,如果其中一個作業已設定 ProtectionLevel.SignOperationContractAttribute ,則會簽署該作業的訊息,但合約中的所有其他訊息都會加密和簽署,包括錯誤訊息。

設定這些值的範圍如下:

ServiceContractAttribute.ProtectionLevel

OperationContractAttribute.ProtectionLevel

FaultContractAttribute.ProtectionLevel

MessageContractAttribute.ProtectionLevel

MessageContractMemberAttribute.ProtectionLevelSystem.ServiceModel.MessageHeaderAttribute 屬性。

MessageContractMemberAttribute.ProtectionLevelSystem.ServiceModel.MessageBodyMemberAttribute 屬性。

當合約上未明確指定保護層級,而且基礎繫結可支援安全性 (不論是在傳輸層級或訊息層級) 時,整個合約的有效保護層級會是 ProtectionLevel.EncryptAndSign。 如果繫結不支援安全性 (例如,BasicHttpBinding),整個合約的有效 System.Net.Security.ProtectionLevelProtectionLevel.None。 結果便是根據端點繫結的不同,用戶端可以要求不同的訊息或傳輸層級的安全性保護,即使當合約指定 ProtectionLevel.None 時亦然。

適用於