簡體   English   中英

帶有 .NET 標准 2.0 的 WCF Web 服務參考

[英]WCF Web Service Reference with .NET standard 2.0

我在 .NET Standard 2.0 項目中生成 WCF Web 服務參考reference.cs ,然后從 .NET 4.7.1 項目使用它,但我得到"Could not establish secure channel for SSL/TLS with authority"

如果我使用 Visual Studio 2015 之外的Add Service Reference生成它。我得到一個類似的 reference.cs 類,如果我將它復制到我的 .NET 標准 2.0 項目中,但我會丟失 WCF Web 服務的異步調用實現。 有什么辦法可以使這項工作?

確保配置綁定。 它們位於 .net 框架項目的 app.config 中,但應封裝在 .NET Standard/.NET Core 中的BasicHttpBinding中。

這樣您就可以根據需要指定安全設置:

    binding.Security.Mode = BasicHttpSecurityMode.Transport;
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
    binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;

從 Nuget 包 System.ServiceModel.Http:

namespace System.ServiceModel
{
    public class BasicHttpBinding : HttpBindingBase
    {
        public BasicHttpBinding();
        public BasicHttpBinding(BasicHttpSecurityMode securityMode);

        public BasicHttpSecurity Security { get; set; }

        public override IChannelFactory<TChannel> BuildChannelFactory<TChannel>(BindingParameterCollection parameters);
        public override BindingElementCollection CreateBindingElements();
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM