ServiceDebugBehavior Classe

Definição

Habilita recursos de depuração e informações de ajuda para um serviço do WCF (Windows Communication Foundation).Enables debugging and help information features for a Windows Communication Foundation (WCF) service.

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
Herança
ServiceDebugBehavior
Implementações

Exemplos

O exemplo de código a seguir mostra como usar um arquivo de configuração para habilitar o recurso de página de ajuda HTML e retornar informações de exceção dentro de uma falha de SOAP para o cliente para fins de depuração, além de habilitar o suporte a metadados.The following code example shows how to use a configuration file to enable the HTML help page feature and return exception information inside a SOAP fault back to the client for debugging purposes, in addition to enabling metadata support. Este arquivo de configuração mostra as seguintes etapas básicas para adicionar suporte para os ServiceDebugBehavior recursos do:This configuration file shows the following basic steps to adding support for the ServiceDebugBehavior features:

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

Comentários

Use as ServiceDebugBehavior Propriedades de um arquivo de configuração ou programaticamente para habilitar o fluxo de informações de exceção gerenciadas para o cliente para fins de depuração, bem como a publicação de arquivos de informações HTML para usuários que navegam no serviço em navegadores da Web.Use the ServiceDebugBehavior properties from a configuration file or programmatically to enable the flow of managed exception information to the client for debugging purposes as well as the publication of HTML information files for users browsing the service in Web browsers.

Defina a IncludeExceptionDetailInFaults propriedade como true para instruir o WCF a retornar informações de exceção gerenciadas em falhas de SOAP para clientes para fins de depuração.Set the IncludeExceptionDetailInFaults property to true to instruct WCF to return managed exception information in SOAP faults to clients for debugging purposes.

Cuidado

Retornar informações de exceção gerenciada aos clientes pode ser um risco de segurança, pois os detalhes da exceção expõem informações sobre a implementação do serviço interno que poderia ser usada por clientes não autorizados.Returning managed exception information to clients can be a security risk because exception details expose information about the internal service implementation that could be used by unauthorized clients. Além disso, embora as ServiceDebugBehavior Propriedades também possam ser definidas programaticamente, pode ser fácil esquecer de desabilitar IncludeExceptionDetailInFaults ao implantar o.In addition, although the ServiceDebugBehavior properties can also be set programmatically, it can be easy to forget to disable IncludeExceptionDetailInFaults when deploying.

Devido aos problemas de segurança envolvidos, é altamente recomendável que:Because of the security issues involved, it is strongly recommended that:

  • Você usa um arquivo de configuração de aplicativo para definir o valor da IncludeExceptionDetailInFaults propriedade como true .You use an application configuration file to set the value of the IncludeExceptionDetailInFaults property to true.

  • Você só faz isso em cenários de depuração controlados.You only do so only in controlled debugging scenarios.

Para obter mais informações sobre os problemas de segurança relacionados a informações de exceção gerenciadas, consulte especificando e manipulando falhas em contratos e serviços.For more information about the security issues related to managed exception information, see Specifying and Handling Faults in Contracts and Services.

As HttpHelpPageEnabled HttpsHelpPageEnabled Propriedades e instruem o serviço a publicar arquivos de ajuda HTML quando o serviço é exibido usando um navegador HTML.The HttpHelpPageEnabled and HttpsHelpPageEnabled properties instruct the service to publish HTML help files when the service is viewed using an HTML browser.

As HttpHelpPageUrl HttpsHelpPageUrl Propriedades e controlam o local da página de ajuda HTML que é exibida.The HttpHelpPageUrl and HttpsHelpPageUrl properties control the location of the HTML help page that is viewed.

Para habilitar ou desabilitar um dos ServiceDebugBehavior recursos usando um arquivo de configuração:To enable or disable one of the ServiceDebugBehavior features using a configuration file:

  1. Adicione um behaviorConfiguration atributo ao elemento de < serviço > para seu serviço WCF.Add a behaviorConfiguration attribute to the <service> element for your WCF service. Os comportamentos de ponto de extremidade são configurados em <endpoint> elementos; comportamentos de serviço em elementos de < serviço > .Endpoint behaviors are configured on <endpoint> elements; service behaviors on <service> elements.

  2. Adicione ou crie uma seção de < percomportamentos > e adicione um elemento de < comportamento > a ele com o nome que corresponde ao behaviorConfiguration valor do atributo da etapa 1.Add to or create a <serviceBehaviors> section and add a <behavior> element to that with the name that matches the behaviorConfiguration attribute value from step 1. Os comportamentos de ponto de extremidade são configurados usando um elemento < EndpointBehaviors > ; os comportamentos de serviço são configurados < > usando um elemento ServiceEndpoints.Endpoint behaviors are configured using an <endpointBehaviors> element; service behaviors are configured using a <serviceBehaviors> element.

  3. Adicione um elemento de < userdebug > ao elemento < Behavior > da etapa 2 e habilite ou desabilite as várias propriedades apropriadas ao seu cenário.Add a <serviceDebug> element to the <behavior> element from step 2 and enable or disable the various properties appropriate to your scenario.

Para obter um exemplo específico, consulte a seção de exemplo.For a specific example, see the Example section.

Construtores

ServiceDebugBehavior()

Inicializa uma nova instância da classe ServiceDebugBehavior.Initializes a new instance of the ServiceDebugBehavior class.

Propriedades

HttpHelpPageBinding

Obtém ou define o acesso de alto nível para a definição de uma associação.Gets or sets high-level access to the definition of a binding.

HttpHelpPageEnabled

Obtém ou define um valor que controla se o WCF (Windows Communication Foundation) publica uma página de ajuda HTML no endereço controlado pela propriedade HttpHelpPageUrl.Gets or sets a value that controls whether Windows Communication Foundation (WCF) publishes an HTML help page at the address controlled by the HttpHelpPageUrl property.

HttpHelpPageUrl

Obtém ou define o local em que o arquivo de ajuda HTML é publicado.Gets or sets the location at which the HTML help file is published.

HttpsHelpPageBinding

Obtém ou define o acesso de alto nível para a definição de uma associação.Gets or sets high-level access to the definition of a binding.

HttpsHelpPageEnabled

Obtém ou define um valor que especifica se o WCF (Windows Communication Foundation) retorna um arquivo de ajuda HTML via HTTPS no endereço controlado pela propriedade HttpsHelpPageUrl.Gets or sets a value that specifies whether Windows Communication Foundation (WCF) returns an HTML help file over HTTPS at the address controlled by the HttpsHelpPageUrl property.

HttpsHelpPageUrl

Obtém ou define o local no qual um arquivo HTML é publicado para recuperação usando HTTPS.Gets or sets the location at which an HTML file is published for retrieval using HTTPS.

IncludeExceptionDetailInFaults

Um valor que especifica se são incluídas informações de exceção gerenciada no detalhe de falhas SOAP retornadas para o cliente para fins de depuração.Gets or sets a value that specifies whether to include managed exception information in the detail of SOAP faults returned to the client for debugging purposes.

Métodos

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Implantações explícitas de interface

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

Implementa o método AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection) para dar suporte ao comportamento.Implements the AddBindingParameters(ServiceDescription, ServiceHostBase, Collection<ServiceEndpoint>, BindingParameterCollection) method to support the behavior.

IServiceBehavior.ApplyDispatchBehavior(ServiceDescription, ServiceHostBase)

Implementa o método ApplyDispatchBehavior(ServiceDescription, ServiceHostBase) para dar suporte ao comportamento.Implements the ApplyDispatchBehavior(ServiceDescription, ServiceHostBase) method to support the behavior.

IServiceBehavior.Validate(ServiceDescription, ServiceHostBase)

Implementa o método Validate(ServiceDescription, ServiceHostBase) para dar suporte ao comportamento.Implements the Validate(ServiceDescription, ServiceHostBase) method to support the behavior.

Aplica-se a