Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I am getting this error when getting response service. I am using this code below


private void GetAvailability(string propName, string propNum)
        {
            try
            {
                GetPropertyCodeSeapines db = new GetPropertyCodeSeapines();
                string soap = @"<?xml version=""1.0"" encoding=""utf-8""?>
                <soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">
                  <soap12:Header>
                    <soapheader xmlns=""http://www.800beachme.com/"">
                      <UserName>*********************</UserName>
                      <Password>*********************</Password>
                    </soapheader>
                  </soap12:Header>
                  <soap12:Body>
                    <SPR_HHVR_AvailabilityByPropertyID xmlns=""http://www.800beachme.com/"">
                      <HHVR_SPR_AVAILABLEDATA_RQ PropertyCode=""" + propNum + @""" PropertyName=""" + propName + @""" />
                    </SPR_HHVR_AvailabilityByPropertyID>
                  </soap12:Body>
                </soap12:Envelope>";

                
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create("*****");
                req.ContentType = "application/soap+xml;";
                req.Method = "POST";
                req.Accept = "*/*";
                req.UserAgent = @"Fiddler";
                req.KeepAlive = true;
                req.ProtocolVersion = HttpVersion.Version10;
                req.ServicePoint.ConnectionLimit = 24;
                req.Headers.Add("UserAgent", "Pentia; MSI");
                ServicePointManager.Expect100Continue = true;
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
              
                //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                ServicePointManager.DefaultConnectionLimit = 9999;
                
                //WebResponse response = req.GetResponse();
                //Stream responseStream = response.GetResponseStream();

                using (Stream stm = req.GetRequestStream())
                {
                    using (StreamWriter stmw = new StreamWriter(stm))
                    {
                        stmw.Write(soap);
                    }
                }

                WebResponse response = req.GetResponse();



Please help me, How can i get rid off from this issue. your help will be appreciated!

What I have tried:

I tried with TLS 1.0, 1.1 and 1.2 but always I am getting this response.
Posted
Updated 29-Sep-17 9:08am
v2

1 solution

I was working with this over the summer for PCI Compliance and the shift in the industry to tighten up security.
I have no solution in code, but will point you in the right direction here.

From what I learned, you have to meet certain requirements.
Your PC:
1. Has to be able to process TLS 1.2 and have a cipher strong/weak enough to support it.
TLS-SSL Settings[^]

2. Your version of .Net has to support TLS 1.2
TLS 1.2 and .NET Support: How to Avoid Connection Errors | Microsoft[^]

As far as the code goes, not every service will support TLS 1.2 so you have to be able to downshift to lower versions, and handle a bad ssl certificate
//Override any SSL Certificate Errors and set the encryption levels
ServicePointManager.ServerCertificateValidationCallback = certificate_Callback.CertificateValidationCallBack;                
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;


A Quick way to edit your pc or server registry for advanced ciphers is to use a tool like this IIS Crypto, but it takes time to learn.
Nartac Software - IIS Crypto[^]

And then study up on what ciphers are OK to use now days, you'll need some older ciphers to connect to exchange server, remote server tools until you upgrade those.
Recommendations for TLS/SSL Cipher Hardening - Acunetix[^]

And learn PCI, in relation to SSL and TLS
PCI 3.1: Stop Using SSL and Outdated TLS Immediately[^]

On a side note,
You really should get the WSDL file and create a service reference to code to, then use the soap client to transmit and receive the soap response.
But you should at least be able to process a TLS Handshake before transmitting your string
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900