This site uses cookies. By continuing, your consent is assumed. Learn more

99.4fm shares

Devtrends wcf data annotation not validating

opinion

By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

I am trying to validate the WCF service request using System. I am using VS with Target Framework v4. Below are my sample request s. DataAnnotations namespace provides attribute classes that are used to define metadata for ASP. Attributes from that namespace are not handled out-of the box by WCF.

Why choose DataAnnotations?

You have to write Your own logic to achieve this. Here is an article describing custom validation of parameters for WCF. This is probably what You need. IsRequired indicates that given member must be present in the model. Not that it must have a value.

This is for your api versioning. For example You could have had in Your Service version 1 a model like this:. But Your client knows nothing about new version and sends You old xml.

Release Notes

That xml will deserialize properly to Your new model but with Name equals null. That way WCF will return an error for old xml and will accept only this structure:. Which is what is happening in Your case.

News feed