title: Invoking a SOAP web service: the request was aborted: Could not create SSL/TLS secure channel
body: <p>I'm trying to invoke a SOAP web service from a .NET application. The web services uses HTTPS (I got that from the URL inside the WSDL) but I can't figure out whether I should invoke it with TLS or SSL. Here's my code:</p>
  
  <pre><code>try
  {
      string soap = "&lt;BigXmlSOAPHeader&gt;&lt;/BigXmlSOAPHeader&gt;"
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ws_uri);
      ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) =&gt;
      {
          return true;
      };
      byte[] bytes;
      bytes = System.Text.Encoding.ASCII.GetBytes(soap);
      request.ContentType = "text/xml; encoding='utf-8'";
      request.Timeout = 1000000000;
      request.ContentLength = bytes.Length;
      request.Method = "POST";
      Stream requestStream = request.GetRequestStream(); // it fails here
      requestStream.Write(bytes, 0, bytes.Length);
      requestStream.Close();
      HttpWebResponse response;
      response = (HttpWebResponse)request.GetResponse();
      Stream responseStream = response.GetResponseStream();
      XmlTextReader reader = new XmlTextReader(responseStream);
  }
  catch (Exception ex)
  {
    DoSomethingWithException(ex);
  }
  </code></pre>
  
  <p>The Exception message is <code>The request was aborted: Could not create SSL/TLS secure channel.</code></p>
  
  <p>When I copied my header (from debugging) and used it in SoapUI to invoke the web service, it worked which means there's no problem with the web service itself.</p>
  
  <p>UPDATE:
  I restarted my application pool in IIS when this occured and it solved the problem. I can't find a logical explanation to this...</p>
  
  <p>Please help.</p>