WCF:ServiceDebugBehavior.IncludeExceptionDetailInFaults 属性设置
作者:C/S框架网  发布日期:2012/03/12 23:26:27
  WCF:ServiceDebugBehavior.IncludeExceptionDetailInFaults 属性设置


IncludeExceptionDetailInFaults 属性:返回客户端以供调试的 SOAP 错误详细信息中是否包含托管异常信息。

设置:
  <serviceDebug includeExceptionDetailInFaults="true" />

可以获取服务端托管异常信息以供客户端调试。



  <behavior name="PurchaseModuleServiceBehavior">


         
<
serviceMetadata httpGetEnabled="true" />


         
<
serviceDebug includeExceptionDetailInFaults="true" />

  </behavior>




如果设置为false,客户端获取的异常信息如下:


贴图图片



FaultExceptionwas unhandled by user code:


The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.



客户端只知道服务端有错误发生,但不知道具体的错误信息,如果将includeExceptionDetailInFaults=True, 客户端能获取到具体的异常信息,如用户自定义异常,或.NET抛出的异常,方便客户端调试程序。




上一篇 下一篇