将WSHttpBinding移动到BasicHttpBinding ....
问题陈述:.Net核心不支持WSHttpBinding。
当我的应用程序在.Net 4.6中时,我使用WSHttpBinding通过以下代码创建与WCF的连接。
var binding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
binding.Security.Message.EstablishSecurityContext = false;
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates.Find(X509FindType.FindByThumbprint, "Thumprint", true)[0];
result = new MyClient(binding, address);
client = result as ClientBase<TInterface>;
client.ClientCredentials.ClientCertificate.Certificate = cert;
现在我将我的应用程序迁移到.Net核心,我发现不支持WSHttpBinding。我计划使用BasicHttpBinding移动并进行以下更改:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;
使用BasicHttpBinding,没有提供以下代码:
binding.Security.Message.EstablishSecurityContext = false;//This code is w.r.t. WSHttpBinding.
所以,我的问题是:这是否可以改变,或者我应该采取其他方式?请协助!