wcfvalidationenterprise-libraryvalidationattributevalidation-application-bl

wcf generated classes and validation application block attributes


I'm new to the validation application block and trying to use it with wcf...

I have a wcf service that has data objects with validation rules defined with attributes, using the validation application block .

On my client side (WPF), I have a service reference. When I update the service reference the generated classes do not have the validation rules attributes in them.

How can I get the rules from the service? Am I missing some step, or is it not possible?


Solution

  • When you use Add Service Reference, proxy classes are created for the service. However, this will not retain all of your Validation Attributes but just create properties corresponding to the service metadata. In order to retain the validation rules you will need to share your service and data contracts between WCF and WPF.

    To do this move all of your service and data contracts into an assembly. WCF and WPF should both reference this assembly. Then you can create your own proxy class using ClientBase or ChannelFactory.

    Since both WCF and WPF are referencing the same classes annotated with the VAB Attributes you can invoke validation in both WCF and WPF using Enterprise Library.