WCF:ServiceDebugBehavior.IncludeExceptionDetailInFaults 属性设置
WCF:ServiceDebugBehavior.IncludeExceptionDetailInFaults 属性设置
IncludeExceptionDetailInFaults 属性:返回客户端以供调试的 SOAP 错误详细信息中是否包含托管异常信息。
设置:
<serviceDebug includeExceptionDetailInFaults="true" />
可以获取服务端托管异常信息以供客户端调试。
如果设置为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抛出的异常,方便客户端调试程序。
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抛出的异常,方便客户端调试程序。
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc
C/S框架网