I have a Web-service .asmx
that receives some elements (parameters or attributes) from an XML . This XML is sometimes received without some element.
How can my Web-service return an error notice that X element is missing from the request?
How can I do it by validating it with the XSD ?
If you're using .NET 3.5 or higher, you can easily validate using
XDocument
andXmlSchemaSet
.Look at this example for the console:
More information in the MSDN documentation .
With information from this StackOverflow answer in English.