CallbackDebugBehavior.IncludeExceptionDetailInFaults 属性

定义

获取或设置一个值,该值控制客户端回调对象是否将 SOAP 错误中的托管异常信息返回到服务。Gets or sets a value that controls whether client callback objects return managed exception information in SOAP faults back to the service.

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

属性值

Boolean

true 如果 WCF 在双工通信中返回 SOAP 错误中的托管客户端回调异常信息以进行服务调试,则为;否则为 falsetrue if WCF returns managed client callback exception information in the SOAP faults for service debugging purposes in duplex communication; otherwise, false. 默认为 falseThe default is false.

示例

下面的代码示例演示一个客户端配置文件,该文件指示 WCF 从 SOAP 消息中的客户端回调对象返回托管异常信息。The following code example shows a client configuration file that instructs WCF to return managed exception information from a client callback object in SOAP messages.

  <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,则可以使客户端回调对象中的托管异常信息回流到该服务,以便进行调试。Set the IncludeExceptionDetailInFaults property to true from an application configuration file or programmatically to enable the flow of managed exception information in a client callback object back to the service for debugging purposes.

注意

将托管异常信息返回到服务可能存在安全风险,因为异常详细信息会公开有关内部客户端实现的信息,而未经授权的服务可能会使用这些信息。Returning managed exception information to services can be a security risk because exception details expose information about the internal client implementation that could be used by unauthorized services. 此外,虽然 CallbackDebugBehavior 属性也可以通过编程方式进行设置,但在部署时容易忘记禁用 IncludeExceptionDetailInFaultsIn addition, although the CallbackDebugBehavior properties can also be set programmatically, it can be easy to forget to disable IncludeExceptionDetailInFaults when deploying.

由于涉及到一些安全问题,因此强烈建议您:Because of the security issues involved, it is strongly recommended that:

  • 使用应用程序配置文件将 IncludeExceptionDetailInFaults 属性的值设置为 trueYou use an application configuration file to set the value of the IncludeExceptionDetailInFaults property to true.

  • 仅在受控调试方案中才这样做。You only do so only in controlled debugging scenarios.

有关与托管异常信息相关的安全问题的详细信息,请参阅 在协定和服务中指定和处理错误For more information about the security issues related to managed exception information, see Specifying and Handling Faults in Contracts and Services.

使用配置文件启用或禁用 CallbackDebugBehavio 的功能To enable or disable a feature of CallbackDebugBehavior using a configuration file

  1. behaviorConfiguration WCF 客户端应用程序的客户端元素添加属性 <endpoint>Add a behaviorConfiguration attribute to the client <endpoint> element for your WCF client application. CallbackDebugBehavior 行为是终结点行为。The CallbackDebugBehavior behavior is an endpoint behavior. 终结点行为在元素上配置 <endpoint> ; 服务行为在 < 服务 > 元素上进行配置。Endpoint behaviors are configured on <endpoint> elements; service behaviors are configured on <service> elements.

  2. 添加到或创建 < endpointBehaviors > 节,并使用与步骤1中的属性值相匹配的名称将 < > 行为元素添加到中 behaviorConfigurationAdd to or create an <endpointBehaviors> section and add a <behavior> element to that with the name that matches the behaviorConfiguration attribute value from step 1. <endpoint>使用 < endpointBehaviors > 元素添加终结点行为,以便在客户端元素中使用。Endpoint behaviors are added for use in a client <endpoint> element using an <endpointBehaviors> element.

  3. < callbackDebug > 元素添加到步骤2中的 < 行为 > 元素,并启用或禁用适用于方案的各种属性。Add a <callbackDebug> element to the <behavior> element from step 2 and enable or disable the various properties appropriate to your scenario.

有关具体示例的信息,请参见“示例”部分。For a specific example, see the Example section. 还可以通过在客户端应用程序配置文件中使用 < callbackDebug > 元素来设置此属性的值。You can also set the values of this attribute by using the <callbackDebug> element in a client application configuration file.

适用于