troubleshooting Question

The request was aborted: Could not create SSL/TLS secure channel

Avatar of mathew_s
mathew_s asked on
2 Comments1 Solution2032 ViewsLast Modified:
I have created a windows service and installed a certificate on my local machine. I am sending an XML query to the remote server and expecting a response back. I am getting an error: The request was aborted: Could not create SSL/TLS secure channel.

The error occurs on the following line:
            using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))

Note  that I have replaced text that is sensitive with blah.
Any ideas?

        public static void CallWebService()
            var _url = "https://blah";
            var _action = "https://blah";

            XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
            HttpWebRequest webRequest = CreateWebRequest(_url, _action);
            InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);

            // begin async call to web request.
            IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);

            // suspend this thread until call is complete. 

            // get the response from the completed web request.
            string soapResult;

            using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult)) //error occurs here!!
                using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
                    soapResult = rd.ReadToEnd();


        private static HttpWebRequest CreateWebRequest(string url, string action)
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.Headers.Add("SOAPAction", action);
            webRequest.ContentType = "text/xml";
            //webRequest.ContentLength = ddd;
            webRequest.Accept = "text/xml";
            webRequest.Method = "POST";

            //create the proxy
            ICredentials credentials = new NetworkCredential("Blah", "");
            IWebProxy webProxy = new WebProxy("", true);
            webProxy.Credentials = credentials;
            webRequest.Proxy = webProxy;

            return webRequest;

        private static XmlDocument CreateSoapEnvelope()
            XmlDocument soapEnvelop = new XmlDocument();
            soapEnvelop.LoadXml(@"<SOAP-ENV:Envelope xmlns:SOAP-ENV="""" xmlns:xsi="""" xmlns:xsd=""""><SOAP-ENV:Body><QueryRequest><Blah><All/></Blah></QueryRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>");
            return soapEnvelop;

        private static void InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)
            using (Stream stream = webRequest.GetRequestStream())

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros