INTRODUCTION
I have a custom ASMX deployed to SharePoint, within that ASMX was a code to call an another SOAP service (written in PHP). On my mockup ASP.NET website all works well. As soon as I transferred the code to SharePoint, I get this error even though I’ve tried to add the SSL certificate of the third party SOAP call to “Manage trusts” section, etc it still didn’t work.
Exception information:
Exception type: WebException
Exception message: The underlying connection was closed: An unexpected error occurred on a send.
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
RESOLUTION
The resolution as apparently very simple!
- Add “using System.Net;”
- Then before you instantiate your web service, you add this line:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
MyWebService service = new MyWebService();
….
Done,
Tommy