.Net Core不支持WSHttpBinding

问题描述 投票:1回答:1

将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.

所以,我的问题是:这是否可以改变,或者我应该采取其他方式?请协助!

wcf .net-core
1个回答
0
投票

我做了同样的事情(从完整的.NET框架转移到.NET核心项目),我找到了there is NO SUPPORT for WCF ...

我所做的是:

1 - Create a .NET STANDARD LIB PROJ ..参考您的SOAP端点(它支持WCF)

2 - Reference your LIB to a .NET CORE PROJECT

希望它能帮到你!!

像:enter image description here

然后引用它像:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.