Here's my problem. I have a middleware web service used by several web clients. The web service is a wrapper service that makes calls to several vendors' web services. The call to the vendor's web service is wrapped in a TryCatch but any exceptions generated aren't getting caught by my web service, they're getting caught in the client apps.
Am I missing something? Is this related to this posting?
Here's a simplified code snippet:
Dim VendorWebservice as New VendorWebservice
Dim VendorResponse As VendorResponse = Nothing
Dim ClientResponse as New CustomClientResponse
Try
VendorResponse = VendorWebservice.VendorWebMethod
Catch ex As Exception
ClientResponse.ErrorMessage = ex.Message
ClientResponse.Status = "VendorError"
Return ClientResponse
End Try
EDIT
To expand upon some of the details... The code runs successfully 99+% of the time. On the rare occaision that there is some issue with the vendor's web site is when this issue is occurring. I've had VS opened for both one of the web clients and the web service and can step through the code from the client to the WS and back. When I can reproduce the issue, I have stepped through the client code to where it calls our web service, then switch to the WS code and step through until it calls the vendor's code and at that point, it jumps back to the client code, without hitting the Catch block or any code after it.
Hope that helps.
EDIT
Some of the posted answers have provided avenues to research, most notibly that there are exceptions that can be created that are not derived from System.Exception. (Who knew?) But I also found out that from .NET 2.0 and later, these non-System.Exceptions are getting wrapped by .NET in a System.Exception. So in theory that should rule non-System.Exceptions out.
Additionally, from my reading, when calling a web service (like my web service is doing) theoretically only two types of exceptions should ever really be seen, System.Net.WebException and System.Web.Services.Protocols.SoapException, both of which derive from System.Exception. I don't know if it is really true if there are only 2 types of exceptions possible when calling a web service, but I'll throw it out there. :)
Still searching for an answer...
EDIT
Reproducing the error condition has proved to be elusive. Every scenario that I've thrown at the code has responded as expected, with the error being caught in the Catch block. While in theory .NET is supposed to be wrapping exceptions that do not derive from System.Exception, the only logical answer appears to agree with Joe's answer that the exception we have experienced does NOT derive from System.Exception and thus is treated as an unhandled exception.