How to Return Errors from an ASMX Web Service?
问题 My web service method returns a collection object, this will serialize nicely, thanks to the way C# web services work! But if my code throws an uncaught exception, I want to instead return a custom error object. Is this possible using C# ASP.NET v2? For example, Normal Operation should return: <Books> <book>Sample</book> <book>Sample</book> </Books> But on error I want <error> <errorMessage></errorMessage> </error> 回答1: Yes, this is possible. What you'll need to look into is the SoapException