I am calling a 3rd party web service, during testing I am simulating what would happen if the web server lost internet connectivity by disabling the network adapter during a web service operation.
I have a simple try/ catch scenario.
The ex.message is : There is an error in XML document (1, 1709).
The ex.InnerException.Message : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
During a 2nd test : Unable to read data from the transport connection: An established connection was aborted by the software in your host machine
My question is rather than catching a general exception, how can I catch a more specific exception relating to the transport? I've already tried a System.Net.Sockets.SocketException, but this is the wrong object type for this operation.
Any ideas?
Just for clarification, I need an error type that only occurs during a network operation fail, because I'm had a case where the web service provider made changes to their WSDL also producing an error in xml... so I need to drill down and get specific with this one...
Tried
catch (System.Net.WebException ex)
catch (System.Web.Services.Protocols.SoapException soapEx)
catch (System.Net.Sockets.SocketException socketException)
None of the above work.
Thanks in advance