Return custom exception data through FaultContract
In an XML Web Service and WCF service, the server side will return any unhandled exception as SoapFault
in the returned message. For WCF service operations, exceptions are returned to the client through two steps:
- Map exception conditions to custom SOAP faults
- Services and client send and receive SOAP faults as exceptions
By default, WCF will return the simple error message or complete exception information (including Callstack) as the Fault content. However, sometimes we want to encapsulate the raw exception information or return some user-friendly error to the client side. To support this kind of customized exception-information format, WCF has provided the FaultContract
and FaultException
features. ...
Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.