Why TransportWithMessageCredential is not supported in .net core?

Viewed 5423

I am trying to consume a SOAP Service in .net core

I want to set the basic httpbinding with security mode as TransportWithMessageCredential

and clientcredentialType as Certificate

but I am getting an error

The value 'TransportWithMessageCredential' is not supported in this context for the binding security property 'securityMode'.

the code looks like this

var client = new SoapCustomClient();

var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
client.ClientCredentials.ClientCertificate.Certificate = certCollection[0];

Am I doing some serious mistake here? Any Solution for the same?

[I am able to achieve this in .net framework but not in .net core]

2 Answers

Just edit the .csproj file after adding the service reference and point these dependencies from 4.4.* to 4.6.*

<ItemGroup> <PackageReference Include="System.ServiceModel.Duplex" Version="4.6.*" /> 
    <PackageReference Include="System.ServiceModel.Http" Version="4.6.*" /> 
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.6.*" /> 
    <PackageReference Include="System.ServiceModel.Security" Version="4.6.*" /> 
</ItemGroup>

and add this

        binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportWithMessageCredential;
        binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
Related