This sample illustrates how to write a SoapExtension for enabling XML Schema validation on incoming SOAP messages. You can turn on validation by using the [Validation] attribute as illustrated here:
...
[Validation]
[WebMethod]
public double Add(double x, double y) {
return x+y;
}
The validation occurs against the XML Schema generated by the .asmx infrastructure by default, although you can point the extension to your custom schema if you desire.
In addition to XML Schema validation, this extension provides support for validating arbitrary XPath assertions as illustrated here:
...
[Assert(“//l > //w“)]
[Validation]
[WebMethod]
public double CalcDistance(double l, double w) {
return l*w;
}
This indicates that the length must be greater than width, an assertion you cannot express with XML Schema (note: you may have to use namespace prefixes depending on your WebMethod configuration).
For details of how this sample works and the functionality it provides, check out my following articles:
Download here.
Posted
Jan 30 2004, 04:56 AM
by
Aaron Skonnard