Normally you check incoming parameters in your public methods using if-then-throw
pattern or Code Contracts.
My question is, how should I validate parameters passed in my WCF service? For example, I've got the following contract:
[OperationContract]
Stock GetStock(string symbol);
I want to ensure that symbol
parameter is not null
or empty string. Should I use the same if-then-throw
pattern or Code Contracts precondition on the service-side? Should I add a FaultContract
attribute to the GetStock
method and return a fault to the client? What's the best parameters validation technique for WCF service?