当我尝试在 dotnet core 2.0 中创建到 WCF 客户端的连接时,我收到平台不支持的错误:
System.PlatformNotSupportedException: 'The value 'TransportWithMessageCredential' is not supported in this context for the binding security property 'securityMode'.'
如果我删除 BasicHttpSecurityMode
,我会收到一个参数异常:
System.ArgumentException: '提供的 URI 方案 'https' 无效;预期为“http”。
代码:
ChannelFactory<BlackBoxContract> factory = null;
BlackBoxContract serviceProxy = null;
Binding binding = null;
binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
factory = new ChannelFactory<BlackBoxContract>(binding, new EndpointAddress("https:......."));;
serviceProxy = factory.CreateChannel();
有人找到了解决方法,因为这可能在长期路线图上吗? https://github.com/dotnet/wcf/issues/8
最佳答案
这已被最新的软件包修复。
<ItemGroup>
<PackageReference Include="System.ServiceModel.Duplex" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.6.0" />
</ItemGroup>
关于c# - .net 核心中的 WCF (TransportWithMessageCredential),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45567598/