I've just tried with EntLib 4 and had no problems; just make sure the ruleset in your validation endpoint behavior matches the ruleset in your rules. This could get tricky if you want to use different rules for different methods. In that case, you can use the
[ObjectValidator("some rule set")] instead like this (using the template service when creating a WCF service project in VS 2008)
CompositeType GetDataUsingDataContract(CompositeType composite);
And the matching validation configuration is
assemblyName="mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089"
type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.RangeValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=18.104.22.168,
name="Range Validator" />
Now, your question is about VAB for a service hosted in IIS; does this imply that when you host your WCF service differently you get the expected result?
Is anyone actually using the VAB to validate request messages and data contracts on the server side, where the WCF services are hosted in IIS?
I have spent about 3 days trying to get this worked out, using configuration AND also using attributes. Still no dice.
"According to the documentation"....
All I have to do is
1. add a behaviorExtension for the validation element in the config file
2. add an endpoint behavior element that contains the validation element with the attribute set to true
3. create a service endpoint whose behaviorConfiguration element is pointed to the named endpoint behavior created in step 2
4. decorate my OperationContract with the [FaultContract(typeOf(ValidationFault))] attribute
5. define my validation rules for the type that I want to validate
Am I missing something in my paraphrasing of the implementation details?
Notes about my environment...
-- I write services and dont trust the consumer of my services to do validation, this rules out using VAB for Client Side Validation.
-- Often times, QA defines the validation rules after my contract is already published to IIS. In addition, I do contract first development, so I dont beleive that I should have to re-compile a data contract when validation rules change, so using
attributes to validate members of a data contract is a moot point.
-- For 99% of all my service operations I pass types that are decorated with the [MessageContract] attribute. The messages have [MessageBody] members for types that are decorated with [DataContract]. I do this because I need to control the message
header and extra information.
Has anyone else had any issues while running the VAB with WCF services hosted in IIS?