I have a WCF
SOAP web service using .Net 4.0 framework. I am using contract first
approach – i.e, service code is generated from hand written WSDL using WCSF Blue tool.
I have following requirement about the request message.
If the price is less than 100, there must not be a tax element, but if it's greater then 100, the tax element is required.
In XPath the expression will be as follows
//t:price[. < 100][not(following::t:tax)] or
//t:price[. >=100][following::t:tax]
I can handle it in C# code of the service. But I would like to define the rule it in the WSDL itself using any XML technology. This will help the client know what is the business validation that the input message should meet. (That is the definition of the business rule and its implementation is in the WSDL itself; not other documentation is to be shared to the client.)
What is the best way to achieve it in WCF? Under which section in the WSDL
I can define the XML validations
so that it will be processed by WCF
?
In the first two references given below, there is an approach mentioned about XPath
and C# handlers (for Web Services Framework). Can't we do so in WCF? Can't C# read the XPath from WSDL? How to do it? Any references?
Note: I am okay to have C# handlers to execute; but the business logic
for validation
should be in XML
Reference
- Extend the ASP.NET WebMethod Framework with Business Rules Validation -by Aaron Skonnard and Dan Sullivan
- WS-Policy and WSE 2.0 Assertion Handlers – by Aaron Skonnard
- Hartmut's Box - The Four Tenets and XML Messaging with WCF
- Message validation with Schema in WCF
- XML validation with Schematron/XSD in C#
- Defining xml in an xsd where an attribute determines the possible contents