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]
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;
This problem is solved in newer versions of System.ServiceModel.* packages (4.7.0 worked for me).
See https://github.com/dotnet/wcf/issues/4045#issuecomment-577854822
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With