FaultContractAttribute.ProtectionLevel 屬性

定義

指定 SOAP 錯誤從繫結要求的保護層級。Specifies the level of protection the SOAP fault requires from the binding.

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

其中一個 ProtectionLevel 值。One of the ProtectionLevel values. 預設為 NoneThe default is None.

備註

您可以使用 FaultDescription.ProtectionLevel 屬性來指定傳送 SOAP 錯誤時,繫結必須加密、簽署,或兩者都進行的程度。Use the FaultDescription.ProtectionLevel property to specify the degree to which the binding must encrypt, sign, or both when sending the SOAP fault. 強烈建議在合約上,就明確指定作業錯誤的安全保護層級需求。It is strongly recommended that an operation's fault explicitly decide the security protection level requirements on the contract. 預設保護層級為 ProtectionLevel.None ,表示您所定義的 SOAP 錯誤訊息不需要加密或數位簽章 (但如果您的系結設定為執行這項作業) ,您的系結可能會提供這項支援。The default protection level is ProtectionLevel.None, meaning that the SOAP fault message you are defining does not require encryption or a digital signature (although your binding may provide this support if it is configured to do so). 如果錯誤訊息含有敏感資訊或可能導致安全性問題的資訊,強烈建議將 ProtectionLevel 屬性設為 ProtectionLevel.EncryptAndSignIf a fault message carries information that is sensitive or can lead to security problems, it is strongly recommended that the ProtectionLevel property be set to ProtectionLevel.EncryptAndSign. 如需有關安全性問題的詳細資訊,請參閱 瞭解保護層級For more about security issues, see Understanding Protection Level.

執行階段的保護行為,是各個保護層級屬性的組合,這些屬性具有階層式結構。The protection behavior at runtime is the combination of the protection-level properties that have a hierarchical structure. 除非針對較窄的範圍明確設定不同的值,否則,設定最外層的值會建立所有較窄範圍的預設值。Setting the outermost value establishes the default setting for all narrower scopes unless a different value for a narrower scope is explicitly set. 在此情況下,外部值仍為所有較窄範圍的預設值 (特別設定的範圍除外)。In this case, the outer value remains the default for all narrower scopes with the exception of that specifically set.

例如,如果 ServiceContractAttribute.ProtectionLevel 設定為 ProtectionLevel.EncryptAndSign ,而且沒有其他更窄的範圍具有保護層級設定,則作業合約中的所有訊息都會經過加密並簽署,包括錯誤訊息。For example, if ServiceContractAttribute.ProtectionLevel is set to ProtectionLevel.EncryptAndSign and no other narrower scopes have protection level settings, all messages in an operation contract are encrypted and signed, including fault messages. 但是,如果其中一個作業的 OperationContractAttribute 設定為 ProtectionLevel.Sign ,則會簽署該作業的訊息,但是合約中的其他所有訊息都會經過加密並簽署,包括錯誤訊息。If, however, one of those operations has the OperationContractAttribute set to ProtectionLevel.Sign, then the messages for that operation are signed but all other messages in the contract are encrypted and signed, including fault messages.

設定這些值的範圍如下:The scopes at which these values are set are:

ServiceContractAttribute.ProtectionLevel

OperationContractAttribute.ProtectionLevel

FaultContractAttribute.ProtectionLevel

MessageContractAttribute.ProtectionLevel

MessageContractMemberAttribute.ProtectionLevelSystem.ServiceModel.MessageHeaderAttribute 屬性。The MessageContractMemberAttribute.ProtectionLevel property on System.ServiceModel.MessageHeaderAttribute.

MessageContractMemberAttribute.ProtectionLevelSystem.ServiceModel.MessageBodyMemberAttribute 屬性。The MessageContractMemberAttribute.ProtectionLevel property on System.ServiceModel.MessageBodyMemberAttribute.

當合約上未明確指定保護層級,而且基礎繫結可支援安全性 (不論是在傳輸層級或訊息層級) 時,整個合約的有效保護層級會是 ProtectionLevel.EncryptAndSignWhen there is no protection level explicitly specified on the contract and the underlying binding supports security (whether at the transport or message level), the effective protection level for the whole contract is ProtectionLevel.EncryptAndSign. 如果繫結不支援安全性 (例如,BasicHttpBinding),整個合約的有效 System.Net.Security.ProtectionLevelProtectionLevel.NoneIf the binding does not support security (such as BasicHttpBinding), the effective System.Net.Security.ProtectionLevel is ProtectionLevel.None for the whole contract. 結果便是根據端點繫結的不同,用戶端可以要求不同的訊息或傳輸層級的安全性保護,即使當合約指定 ProtectionLevel.None 時亦然。The result is that depending upon the endpoint binding, clients can require different message or transport level security protection even when the contract specifies ProtectionLevel.None.

適用於