CallbackDebugBehavior.IncludeExceptionDetailInFaults 屬性

定義

取得或設定值,這個值控制用戶端回呼物件是否將 SOAP 錯誤中的 Managed 例外狀況資訊傳回給服務。

public:
 property bool IncludeExceptionDetailInFaults { bool get(); void set(bool value); };
public bool IncludeExceptionDetailInFaults { get; set; }
member this.IncludeExceptionDetailInFaults : bool with get, set
Public Property IncludeExceptionDetailInFaults As Boolean

屬性值

true 如果 WCF 傳回 SOAP 錯誤中的 Managed 用戶端回呼例外狀況資訊,以用於雙工通訊中的服務偵錯用途;否則為 false 。 預設為 false

範例

下列程式碼範例顯示用戶端組態檔,指示 WCF 從 SOAP 訊息中的用戶端回呼物件傳回 Managed 例外狀況資訊。

  <client>
      <endpoint 
        address="http://localhost:8080/DuplexHello" 
        binding="wsDualHttpBinding"
        bindingConfiguration="WSDualHttpBinding_SampleDuplexHello"
        contract="SampleDuplexHello" 
        name="WSDualHttpBinding_SampleDuplexHello"
        behaviorConfiguration="enableCallbackDebug">
      </endpoint>
  </client>
<behaviors>
  <endpointBehaviors>
    <behavior name="enableCallbackDebug">
      <callbackDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </endpointBehaviors>
</behaviors>

備註

透過應用程式組態檔或以程式設計方式,將 IncludeExceptionDetailInFaults 屬性設定為 true,讓用戶端回呼物件中的 Managed 例外狀況資訊流動回到服務,以供偵錯之用。

警告

將 Managed 例外狀況資訊傳回服務可能導致安全性風險,因為例外狀況詳細資料會公開未授權的服務可使用的內部用戶端實作相關資訊。 此外,雖然也能以程式設計方式設定 CallbackDebugBehavior 屬性,不過在部署時很容易會忘記停用 IncludeExceptionDetailInFaults

由於牽涉到安全性議題,我們強烈建議您:

如需與 Managed 例外狀況資訊相關的安全性問題詳細資訊,請參閱 在合約和服務中指定及處理錯誤

若要使用組態檔啟用或停用 CallbackDebugBehavior 的功能

  1. behaviorConfiguration將 屬性新增至 WCF 用戶端應用程式的用戶端< 端點 >專案。 CallbackDebugBehavior 行為是端點行為。 端點行為是在元素上 <endpoint> 設定;服務行為是在服務 > 元素上設定 <

  2. 將 新增至或建立< endpointBehaviors >區段,並將行為 > 專案新增 <至,其名稱符合 behaviorConfiguration 步驟 1 的屬性值。 端點行為會新增,以在用戶端< 端點 >元素中使用< endpointBehaviors >元素。

  3. < 將 callbackDebug >元素新增至步驟 2的行為專案, <>並啟用或停用適合您案例的各種屬性。

如需特定範例,請參閱<範例>一節。 您也可以在用戶端應用程式組態檔中使用< callbackDebug >元素來設定此屬性的值。

適用於