Search code examples
c#wcf

WCF Error: "mismatch of the security binding between the client and the server"


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.


Solution

  • 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;
    }