If you service has operations that accept message or data contracts, use schemas to validate your messages
Jason Taylor, Prashant Bansode, Carlos Farre, Madhu Sundararajan, Steve Gregersen
If you service has operations that accept message or data contracts, use schemas to validate your messages. Message validation provides a way to validate messages when operations consume message contracts or data contracts which are not possible to validate
with parameter validation. It allows the creation of validation logic inside the schemas, providing more flexibility and less development time. Schema validation occurs before serializing or encrypting the message. In order to reduce development time you can
start by using the service.xsd schema file that is generated when you add a service reference to your client.
The following steps briefly show you how to perform message validation using schemas.
- Use the schema.xsd schema file that is created, by svcutil.exe, when you add a service reference or create a schema that represents the operations of your service and the types consumed by those operations.
- Create a .NET class that implements a custom client message inspector and custom dispatcher message inspector to validate the messages sent and received by the service.
- Implement a custom endpoint behavior to enable message validation on both the client and the service.
- Implement a custom configuration element on the class that allows you to expose the extended custom endpoint behavior in the configuration file of the service or the client.