In our project we have had great problems when debugging web services in Visual Studio. For about half of the the request on of two exceptions has been thrown:
System.Net.WebException: The request failed with HTTP status 400: Bad Request.
System.Net.Sockets.SocketException: The underlying connection was closed
After some looking into I found a solution and it was (as ever) quite easy. You simply have to set credentials on the web service as follows:
Dim m_wsService
m_wsSystemName.SystemNameService = New wsSystemName.SystemNameService
m_wsService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
m_wsService.PreAuthenticate = True
I have not observed this problem in C# so I presume that it is VB.NET related… or I might just be bad.