.net核心中的WCF(TransportWithMessageCredential)

当我尝试在dotnet core 2.0中创建与WCF客户端的连接时,我收到一个不支持的平台错误:

System.PlatformNotSupportedException: 'The value 'TransportWithMessageCredential' is not supported in this context for the binding security property 'securityMode'.' 

如果我删除BasicHttpSecurityMode ,我收到一个参数exception:System.ArgumentException:’提供的URI方案’https’无效; 预计’http’。’

码:

 ChannelFactory factory = null; BlackBoxContract serviceProxy = null; Binding binding = null; binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); factory = new ChannelFactory(binding, new EndpointAddress("https:......."));; serviceProxy = factory.CreateChannel(); 

任何找到解决方法的人都可能在长期路线图中? https://github.com/dotnet/wcf/issues/8

实际上找到了一个有效的解决方法,你可以使用一个包: https : //github.com/gravity00/SimpleSOAPClient

 using SimpleSOAPClient; using SimpleSOAPClient.Handlers; using SimpleSOAPClient.Helpers; using SimpleSOAPClient.Models; using SimpleSOAPClient.Models.Headers; ... _client = SoapClient.Prepare().WithHandler(new DelegatingSoapHandler()); _client.HttpClient.DefaultRequestHeaders.Clear(); _client.HttpClient.DefaultRequestHeaders.Add("SOAPAction", "Action..."); var requestEnvelope = SoapEnvelope .Prepare() .Body(request) .WithHeaders(KnownHeader.Oasis.Security.UsernameTokenAndPasswordText(Username, Password)); var responseEnvelope = _client.Send(Url, "CanNotBeEmpty", requestEnvelope); 

得到这样的工作,作为一个魅力……