ServiceDebugElement 類別

定義

表示組態項目,指定 Windows Communication Foundation (WCF) 服務的偵錯和說明資訊功能。 此類別無法獲得繼承。

public ref class ServiceDebugElement sealed : System::ServiceModel::Configuration::BehaviorExtensionElement
public sealed class ServiceDebugElement : System.ServiceModel.Configuration.BehaviorExtensionElement
type ServiceDebugElement = class
    inherit BehaviorExtensionElement
Public NotInheritable Class ServiceDebugElement
Inherits BehaviorExtensionElement
繼承
繼承

範例

下列程式碼範例示範如何使用組態檔來啟用 HTML 說明頁功能,並將 SOAP 錯誤內部的例外狀況資訊傳回至用戶端,以供偵錯之用 (除了啟用中繼資料支援)。

<configuration>
  <system.serviceModel>
    <services>
      <!-- 
        Step 1. Add a behaviorConfiguration attribute
        in the <service> element.
      -->
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="metadataAndDebug">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService" />
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
        />
        <endpoint
           address="mex"
           binding="mexHttpBinding"
           contract="IMetadataExchange"
        />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <!-- 
          Step 2. Inside a <serviceBehaviors> section, add 
          a name attribute in the <behaviors> element that 
          matches the behaviorConfiguration attribute in the
          <service> element above.
        -->
        <behavior name="metadataAndDebug">
          <serviceMetadata 
            httpGetEnabled="true" 
            httpGetUrl=""
          />
          <!-- 
            Step 3. Add a <serviceDebug> element and 
            modify the various attributes that suit your 
            scenario.
          -->
          <serviceDebug 
            httpHelpPageEnabled="true" 
            includeExceptionDetailInFaults="true"
          />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

備註

如果您將 IncludeExceptionDetailInFaults 屬性以程式設計的方式設定為 true,就可以讓 Managed 例外狀況資訊傳送至用戶端以便偵錯,以及發行 HTML 資訊檔案,在 Web 瀏覽器中瀏覽該服務的使用者便可以存取這些檔案。

警告

將 Managed 例外狀況資訊傳回至服務可能會有安全性風險。 這是因為例外狀況細節會公開內部用戶端實作的相關資訊,可能會被未經授權的服務加以利用。

HttpHelpPageEnabledHttpsHelpPageEnabled 屬性會在使用 HTML 瀏覽器檢視服務時,指示服務要發行 HTML 說明檔案。

HttpHelpPageUrlHttpsHelpPageUrl 屬性會控制所檢視的 HTML 說明頁的位置。

如果要使用組態檔啟用或停用其中一項 ServiceDebugElement 功能,必須:

  1. behaviorConfiguration將 屬性新增至< WCF 服務的服務 >專案。 (端點行為是在元素上 <endpoint> 設定;服務元素上的< 服務 >行為。)

  2. 將 新增至或建立< serviceBehaviors >區段,並將行為 > 專案新增 <至該區段,其名稱符合 behaviorConfiguration 步驟 1 中的屬性值。 (端點行為是使用< endpointBehaviors 元素來設定;服務行為是使用 serviceBehaviors >> 元素來設定。 <

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

如需特定範例,請參閱<範例>一節。

建構函式

ServiceDebugElement()

初始化 ServiceDebugElement 類別的新執行個體。

屬性

BehaviorType

取得此行為項目的型別。

ConfigurationElementName

取得這個組態項目的名稱。

(繼承來源 ServiceModelExtensionElement)
CurrentConfiguration

取得最上層 Configuration 執行個體的參考,這個執行個體表示目前 ConfigurationElement 執行個體所屬的組態階層架構。

(繼承來源 ConfigurationElement)
ElementInformation

取得 ElementInformation 物件,其中包含 ConfigurationElement 物件之不可自訂的資訊和功能。

(繼承來源 ConfigurationElement)
ElementProperty

取得表示 ConfigurationElementProperty 物件本身的 ConfigurationElement 物件。

(繼承來源 ConfigurationElement)
EvaluationContext

取得 ConfigurationElement 物件的 ContextInformation 物件。

(繼承來源 ConfigurationElement)
HasContext

取得值,指出 CurrentConfiguration 屬性是否為 null

(繼承來源 ConfigurationElement)
HttpHelpPageBinding

取得或設定字串值,這個值會指定當使用 HTTP 來存取服務說明頁面時,所要使用的繫結。

HttpHelpPageBindingConfiguration

取得或設定字串,這個字串會指向定義 HttpHelpPageBinding 中所指定繫結的額外組態資訊之 XML 區段。

HttpHelpPageEnabled

取得或設定值,指出 Windows Communication Foundation (WCF) 是否在 HttpHelpPageUrl 屬性指定的位址發佈 HTML 說明頁。

HttpHelpPageUrl

取得或設定 HTML 說明檔的發行位置。

HttpsHelpPageBinding

取得或設定字串值,這個值會指定當使用 HTTPS 來存取服務說明頁面時,所要使用的繫結。

HttpsHelpPageBindingConfiguration

取得或設定字串,這個字串會指向定義 HttpsHelpPageBinding 中所指定繫結的額外組態資訊之 XML 區段。

HttpsHelpPageEnabled

取得或設定值,指定 Windows Communication Foundation (WCF) 是否會在由 HttpsHelpPageUrl 屬性所指定的位址,透過 HTTPS 傳回 HTML 說明檔。

HttpsHelpPageUrl

取得或設定發行 HTML 說明檔以使用 HTTPS 進行擷取的位置。

IncludeExceptionDetailInFaults

取得或設定值,指定是否要在傳回至用戶端以進行偵錯的 SOAP 錯誤詳細資料中包含 Managed 例外狀況資訊。

Item[ConfigurationProperty]

取得或設定此組態項目的屬性 (Property) 或屬性 (Attribute)。

(繼承來源 ConfigurationElement)
Item[String]

取得或設定此一組態項目的屬性或子項目。

(繼承來源 ConfigurationElement)
LockAllAttributesExcept

取得已鎖定屬性的集合。

(繼承來源 ConfigurationElement)
LockAllElementsExcept

取得已鎖定項目的集合。

(繼承來源 ConfigurationElement)
LockAttributes

取得已鎖定屬性的集合。

(繼承來源 ConfigurationElement)
LockElements

取得已鎖定項目的集合。

(繼承來源 ConfigurationElement)
LockItem

取得或設定值,指出此項目是否已被鎖定。

(繼承來源 ConfigurationElement)
Properties

取得屬性的集合。

(繼承來源 ConfigurationElement)

方法

CopyFrom(ServiceModelExtensionElement)

將指定之組態項目的內容複製到這個組態項目。

CreateBehavior()

根據目前的組態設定來建立行為延伸。

(繼承來源 BehaviorExtensionElement)
DeserializeElement(XmlReader, Boolean)

從組態檔讀取 XML。

(繼承來源 ConfigurationElement)
Equals(Object)

將目前的 ConfigurationElement 執行個體與指定的物件相比較。

(繼承來源 ConfigurationElement)
GetHashCode()

取得表示目前 ConfigurationElement 執行個體的唯一值。

(繼承來源 ConfigurationElement)
GetTransformedAssemblyString(String)

傳回指定之組件名稱的轉換版本。

(繼承來源 ConfigurationElement)
GetTransformedTypeString(String)

傳回指定之型別名稱的轉換版本。

(繼承來源 ConfigurationElement)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
Init()

ConfigurationElement 物件設定為它的初始狀態。

(繼承來源 ConfigurationElement)
InitializeDefault()

用來初始化 ConfigurationElement 物件的預設值集。

(繼承來源 ConfigurationElement)
IsModified()

取得值,指出這個組態項目是否經過修改。

(繼承來源 ServiceModelExtensionElement)
IsReadOnly()

取得值,這個值表示 ConfigurationElement 物件是否唯讀。

(繼承來源 ConfigurationElement)
ListErrors(IList)

將這個 ConfigurationElement 物件中和所有子項目中的無效屬性錯誤加入傳遞的清單。

(繼承來源 ConfigurationElement)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnDeserializeUnrecognizedAttribute(String, String)

取得值,指出在還原序列化程序中是否遇到未知的屬性 (Attribute)。

(繼承來源 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

取得值,指出在還原序列化程序中是否遇到未知的項目。

(繼承來源 ConfigurationElement)
OnRequiredPropertyNotFound(String)

在找不到必要的屬性時擲回例外狀況 (Exception)。

(繼承來源 ConfigurationElement)
PostDeserialize()

還原序列化之後呼叫。

(繼承來源 ConfigurationElement)
PreSerialize(XmlWriter)

序列化之前呼叫。

(繼承來源 ConfigurationElement)
Reset(ConfigurationElement)

重設這個組態項目物件的內部狀態,包括鎖定和屬性集合。

(繼承來源 ServiceModelExtensionElement)
ResetModified()

在衍生類別中實作時,將 IsModified() 方法的值重設為 false

(繼承來源 ConfigurationElement)
SerializeElement(XmlWriter, Boolean)

將這個組態項目的內容寫入組態檔。

(繼承來源 ServiceModelExtensionElement)
SerializeToXmlElement(XmlWriter, String)

在衍生類別中實作時,將此組態項目的外部標記寫入組態檔中。

(繼承來源 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

將屬性設定為指定的值。

(繼承來源 ConfigurationElement)
SetPropertyValueIfNotDefaultValue<T>(String, T)

如果值不是預設值,則設定組態項目的屬性值。

(繼承來源 ServiceModelConfigurationElement)
SetReadOnly()

設定 IsReadOnly() 物件和所有子項目的 ConfigurationElement 屬性。

(繼承來源 ConfigurationElement)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

修改 ConfigurationElement 物件,以移除不應該儲存的所有值。

(繼承來源 ConfigurationElement)

適用於

另請參閱