This is a mirror of official site: http://jasper-net.blogspot.com/

Integrate Validation Block with WCF

| Thursday, October 6, 2011
Introduction

Validation block is used for validation purposes and supports technology specific integration features such WPF and WCF. It offers an easy and relatively simpler way to validate data compared with the validation methods provided by most technologies. I will focus on how to integrate the validation block in Microsoft Enterprise Library 5.0 with WCF.

You can learn what the validation block is and how to use it in your projects from the following article: Microsoft Enterprise Library 5.0 - Introduction to Validation Block.

Background

WCF employs its own validation methods through the implementation of the IParameterInspector interface. You can find a good article showing how to consume the IParameterInspector interface for validation from the following address: How to: Perform Input Validation in WCF.

This method actually requires more effort and offers more complex ways than the validation block does. Through the validation block, you just focus on what to validate rather than how to validate. This makes the validation block appeal. Also, it prevents you from complexities, writing your own validations and maintaining them.
How to configure

Although it saves you from complexities, I dream of a technology without configuration, but nice news, because you just need to put the following setting into the configuration of your WCF.

<system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="validation"
             type="Microsoft.Practices.EnterpriseLibrary.
                    Validation.Integration.WCF.ValidationElement,
                  Microsoft.Practices.EnterpriseLibrary.
                    Validation.Integration.WCF,
                  Version=5.0.414.0,
                  Culture=neutral,
                  PublicKeyToken=31bf3856ad364e35" />
      </behaviorExtensions>
    </extensions>
    .......
</system.serviceModel>


Read more: Codeproject
QR: IntegrateValidationBlock.aspx

Posted via email from Jasper-net

0 comments: