wcf entry (10) - abnormal feedback

This article demo has been uploaded to GitHub: xinyuehtx / WCFdemo

This blog will explain how to set up the service of abnormal feedback


Introduced on a blog wcf entry (9) - exception handling mechanism _wcf, c # _ Huangteng Xiao's blog -CSDN blog how to use error feedback agreement specified exceptions, but often there is some abnormality is unexpected. This one will explain how to use the service back abnormal behavior is not specified

Abnormal feedback is not specified

Here we make some modifications to the previous example

First, remove the incorrect service interface Agreement

Here Insert Picture Description

In the service implementation, set IncludeExceptionDetailInFaultsto True. (If you only expect feedback anomalies in the commissioning phase, can be used ServiceDebugBehavior.IncludeExceptionDetailInFaultsinstead)

And directly thrown in the realization of the operation Agreement

Here Insert Picture Description

In this time we changed to capture clientFaultException

Here Insert Picture Description

We caught exception in the client, and Detailservice operations to find the actual properties of anomalies

Here Insert Picture Description

note

This example does not specify exceptions and handle on a blog wcf entry (9) - exception handling mechanism _wcf, c # _ Huangteng Xiao's blog -CSDN blog in the process specified exceptions, the principle is the same.

So the question is the same, we can not handle OneWay

summary

We studied the WCF service IncludeExceptionDetailInFaults, its features are

  • You can specify the server error feedback the client does not need to specify the type of display
  • You can configure debug mode
  • One-way operation can not handle

Reference links:

Published 54 original articles · won praise 0 · Views 2424

Guess you like

Origin blog.csdn.net/htxhtx123/article/details/104243911