trying to get contents of XML doc while in ValidationEventHandler
|
| trying to get contents of XML doc while in ValidationEventHandler | Hello,
I'm looking for help trying to get the contents of the XML document while in the ValidationEventHandler for XmlReaderSettings. Here is what I mean:
We need to be able to validate the content of SOAP messages which are coming into a web service. These XML messages might be missing elements, or have incorrect values in enums, etc. We found that during the deserialization of the XML in these messages, if there are missing elements which are ints and floats, then these elements are added back in by the web service with default values. Missing enums are added back in with first value in the enum. And so forth.
This is not good, so we decided to add a SOAP extension to do XML validation before getting to the web service. We used a WSValidation SOAP Extension adapted from an article on MSDN.
We were able to get the validation working and are logging the exception message, etc. We would like to log the XML message itself, but have not been able to find a way to do so. If a validation error or warning occurs a ValidationEventHandler is called. There are two parameters passed into the ValidationEventHandler:
sender (which is an XmlReader or XsdValidationReader, not sure which) ValidationEventArgs
Neither of these objects appear to give you a link back to the XML message that contained the invalid element. You would think the "sender" object would, but it seems to be primarily concerned with reading a tag at a time, and there is no way, I think, to get the entire XML document out.
Any suggestions on how we can do this? Without serializing the XML message into a string, putting that into a class-level variable and then getting at it within the ValidationEventHandler?
Thank you! Trevor Brierly
|
|
|
|
|
 | Members Area | |
|
 | Last Web Marketing |
|
|
|
|
 | Last Programming Tips |
|
|
|
|
 | Last News |
|
|
|
|
|
|