I have a WCF Webservice and in every Method I’m returning a Response class in which I have a ResponseCode (OK, Error, Etc.. ) and a Data Property ( the actual object i will return, these are different depending on the webservice method ), but now I’m returning a list of this objects (SearchResult) but when I’m updating the reference on the client, the SearchResult class is left out. Are there any Import attributes with which i can mark the class so it will be added to the Reference.cs file?
Share
You have to mark the class with the
[DataContract]attribute.Additionally, when an exception occurs on you service, it’s not good practise to return an error code in your response object to the callers, because you are creating extra work for your callers, who will need to interrogate the response object to know if the call was successful or not.
It’s better to define known exceptions using Fault Contracts. This will mean your consumers can just wrap the call to your service in a try and catch any exceptions they want to in a more natural way.