ServiceDebugBehavior クラス

定義

Windows Communication Foundation (WCF) サービスのデバッグ機能とヘルプ情報機能を有効にします。

public ref class ServiceDebugBehavior : System::ServiceModel::Description::IServiceBehavior
public class ServiceDebugBehavior : System.ServiceModel.Description.IServiceBehavior
type ServiceDebugBehavior = class
    interface IServiceBehavior
Public Class ServiceDebugBehavior
Implements IServiceBehavior
継承
ServiceDebugBehavior
実装

構成ファイルを使用して、HTML ヘルプ ページ機能を有効にし、メタデータのサポートを有効にすると共に、デバッグのために SOAP エラー内の例外情報をクライアントに返す方法を次のコード例に示します。 この構成ファイルは、ServiceDebugBehavior 機能のサポートを追加するための次の基本手順を示します。

<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>

注釈

構成ファイルまたはプログラムから ServiceDebugBehavior プロパティを使用すると、デバッグ目的でクライアントへのマネージド例外情報のフロー、および Web ブラウザーでサービスをブラウズするユーザー向けの HTML 情報ファイルの公開を有効にできます。

プロパティを IncludeExceptionDetailInFaultstrue 設定して、デバッグ目的で SOAP エラーのマネージド例外情報をクライアントに返すように WCF に指示します。

注意事項

マネージド例外情報をクライアントに戻すことは、セキュリティ リスクになり得ます。これは、例外の詳細が、非承認のクライアントで使用可能な内部サービスの実装についての情報を公開するからです。 さらに、ServiceDebugBehavior プロパティをプログラムで設定することはできますが、配置するときに IncludeExceptionDetailInFaults を無効にすることを忘れがちになります。

セキュリティの問題にかかわるので、以下を強くお勧めします。

  • IncludeExceptionDetailInFaults プロパティの値を true に設定するには、アプリケーション構成ファイルを使用します。

  • これは、制御されたデバッグ シナリオの場合に限って行います。

マネージド例外情報に関連するセキュリティの問題の詳細については、「 コントラクトとサービスでのエラーの指定と処理」を参照してください。

HttpHelpPageEnabled プロパティおよび HttpsHelpPageEnabled プロパティにより、サービスが HTML ブラウザーを使用して表示されるときに HTML ヘルプ ファイルを公開できます。

HttpHelpPageUrl プロパティおよび HttpsHelpPageUrl プロパティは、表示される HTML ヘルプ ページの位置を制御します。

構成ファイルを使用していずれかの ServiceDebugBehavior 機能を有効または無効にするには、以下を行う必要があります。

  1. WCF サービスのbehaviorConfigurationサービス>要素に< 属性を追加します。 エンドポイントの動作はエンドポイント要素で<>構成され、サービス要素ではサービス>動作が<構成されます。

  2. serviceBehaviors> セクションに追加または作成<し、<手順 1 の属性値と一致する名前を持つ behavior> 要素をbehaviorConfiguration追加します。 エンドポイントの動作は endpointBehaviors> 要素を<使用して構成されます。サービス動作は serviceBehaviors> 要素を<使用して構成されます。

  3. 手順 2 の behavior> 要素に serviceDebug 要素を<追加し、シナリオに適したさまざまなプロパティを有効または無効にします。><

個々の例については、「使用例」のセクションを参照してください。

コンストラクター

ServiceDebugBehavior()

ServiceDebugBehavior クラスの新しいインスタンスを初期化します。

プロパティ

HttpHelpPageBinding

バインディングの定義への高レベルのアクセスを取得または設定します。

HttpHelpPageEnabled

Windows Communication Foundation (WCF) が、HttpHelpPageUrl プロパティで制御されるアドレスに HTML ヘルプ ページを公開するかどうかを制御する値を取得または設定します。

HttpHelpPageUrl

HTML ヘルプ ファイルが公開される場所を取得または設定します。

HttpsHelpPageBinding

バインディングの定義への高レベルのアクセスを取得または設定します。

HttpsHelpPageEnabled

Windows Communication Foundation (WCF) が、HttpsHelpPageUrl プロパティで制御されるアドレスに HTTPS を介して HTML ヘルプ ファイルを返すかどうかを指定する値を取得または設定します。

HttpsHelpPageUrl

HTTPS を使用した取得のために、HTML ファイルが公開される場所を取得または設定します。

IncludeExceptionDetailInFaults

デバッグの目的でクライアントに返される SOAP エラーの詳細に、マネージド例外情報を含めるかどうかを指定する値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

IServiceBehavior.AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection)

AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection) メソッドを実装して動作をサポートします。

IServiceBehavior.ApplyDispatchBehavior(ServiceDescription, ServiceHostBase)

ApplyDispatchBehavior(ServiceDescription, ServiceHostBase) メソッドを実装して動作をサポートします。

IServiceBehavior.Validate(ServiceDescription, ServiceHostBase)

Validate(ServiceDescription, ServiceHostBase) メソッドを実装して動作をサポートします。

適用対象