O'Reilly logo

Programming WCF Services by Juval Lowy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Faults

Any service operation can at any moment encounter an unexpected error. The question is how (if at all) that error should be reported back to the client. Concepts such as exceptions and exception handling are technology-specific and should not transcend the service boundary. In addition, typically error handling is a local implementation detail that should not affect the client, partly because the client may not care about the details of the errors (other than the fact that something went wrong), but mostly because in a well-designed application, the service is encapsulated so that the client does not have anything meaningful to do about the error anyway. A well-designed service should be autonomous as much as possible, and should not depend on its client to handle and recover the error. Anything beyond a blank error notification should in fact be part of the contractual interaction between the client and the service. This chapter describes just how the service and the client should handle these declared faults, and how you can extend and improve on the basic mechanism.

Errors and Exceptions

In raw .NET programming, any unhandled exception immediately terminates the process it took place in. That is not the WCF behavior, however. If a service call on behalf of one client causes an exception, it must not be allowed to take down the hosting process. Other clients accessing the service, or other services hosted by the same process, should not be affected. As a result, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required