0

So I have two projects calling the same 3rd party SOAP service. Both projects (project A & project B) have the same config and both are running .NET 4.7.2. Project B works perfectly but yet project A is throwing the below exception:

An error occurred while making the HTTP request to https://XXXXXXXXXX. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.

I have set the Security Protocol in project A to match project B(Ssl3 && Tls). I have also tried using HTTP instead of HTTPS.

Project A - Web Api Project .NET 4.7.2

Project B - Console App .NET 4.7.2

Any suggestions would be appreciated.

Selim Yildiz
  • 5,254
  • 6
  • 18
  • 28
Pieter Alberts
  • 829
  • 1
  • 7
  • 23
  • Try copying the binding information from the Console app to the Web API project's web.config. – Ankush Jain Mar 04 '20 at 05:49
  • This may also help -https://stackoverflow.com/a/33084791/1273882 – Ankush Jain Mar 04 '20 at 05:53
  • Thanks, but the configs match and I have set the Security protocol as per link below: https://stackoverflow.com/questions/2013880/wcf-error-this-could-be-due-to-the-fact-that-the-server-certificate-is-not-conf/33084791#33084791 – Pieter Alberts Mar 04 '20 at 05:56
  • Are you using a client proxy class to call the 3rd party SOAP service? Please post the complete steps of calling the SOAP service, plus the code snippets. I suspect if you are calling the SOAP over an identical service endpoint address. According to the error details, in my word, it either is the server-side issue or mismatch of the client binding (if you generate the binding by adding service reference). – Abraham Qian Mar 06 '20 at 03:16

1 Answers1

1

Adding proxy server settings(unaware we had one) resolved my issue.

See example code below:

private string SendDataExample()
{
    using (var client = new ServiceClient())
    {
        SetProxy(client.Endpoint.Binding as BasicHttpBinding);
    }   
}           

private void SetProxy(BasicHttpBinding binding)
{
    binding.ProxyAddress = new Uri($"http://localHost:8080");
    binding.BypassProxyOnLocal = false;
    binding.UseDefaultWebProxy = false;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
}
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Pieter Alberts
  • 829
  • 1
  • 7
  • 23