Hey,
I've been looking for ages to try to find a way to catch and log invalid requests to an ASMX webservice. By invalid requests, I mostly mean invalid SOAPAction values or inbound XML that doesn't validate against the WSDL. I can easily trap exceptions thrown from my own code once the SOAP handlers pass the commands down to my code, but I'm having absolutely no luck catching anything that goes wrong before it hands over that control.
So far I've tried making a SoapExtension and using the ProcessMessage step and trying to catch the errors but it appears they're caught further up the tree, as all I get is an Initialize event then it falls over without ever reaching ProcessMessage. I've also tried a global.asax, and I at least got to log the entire request there, but the error event doesn't fire cause .NET figures the ASMX has already handled it by sending back a Soap Fault/Soap Exception. I've even tried reading the output stream in the finished request event and was figuring I'd parse the XML for soap errors then just log all the raw data, but I couldn't get it to read the outputstream (presumably cause it's already being sent).
There's a part of me saying "It's not your code that has the error, it's theirs!", but the problem is when people can't work out how to use an API they're generally also too stupid to provide good debug info for us to find out what they're doing wrong. I've had to set it up before to just email me all raw input data from the asax that matched a set of rules to try to track down issues, and that just strikes me as horrible. Next stop is using reflection to trawl over the .NET assemblies to try to find somewhere where I can tie in or override functionality to get my hands on the error.
Anyone already butted heads with this issue before? Is this just something you can't do in an ASMX or is there some silly little thing I'm missing?