Handling Exceptions

This topic provides information about exceptions in the DPWS stack.


The DPWS device stack is built to catch and handle most of the exceptions that can happen during the processing of Web Services messages. Most methods in the processing chain catch the exception and either return a fault message or return null. Null return values are handled in the transport services, where they are converted to exception faults and sent to the listening client. A debug method is also produced. Exceptions will never cause the stack to stop operating.


The DPWS device stack returns Addressing and Eventing faults where appropriate, and Exception faults for everything else. If one of your operations needs to return a fault, you can do so using the classes in the Ws.Services.Faults namespace. The Ws.Services.Faults.WsFault.RaiseFault method takes one of three enumerations as its second parameter, allowing you to create faults of any of the following three types.

Enumeration Meaning
WsExceptionFaultType Exception fault
WsWsaFaultType Addressing fault
WsWseFaultType Eventing fault