我在.NET Standard 2.0项目中生成WCF Web服务参考reference.cs
,然后在.NET 4.7.1项目中使用它,但我得到了"Could not establish secure channel for SSL/TLS with authority"
如果我使用Add Service Reference
生成它,除了visual studio 2015.我得到一个类似的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();
}
}