【发布时间】:2020-03-25 07:38:39
【问题描述】:
在 .net core 3.1 中无论 basicHttpBinding 还是 wsHttpBinding 都收到以下错误消息:
SecurityAccessDeniedException: The security token could not be authenticated or authorized
System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, string action, MessageVersion version, FaultConverter faultConverter)
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ref ProxyRpc rpc)
System.ServiceModel.Channels.ServiceChannel.EndCall(string action, object[] outs, IAsyncResult result)
System.ServiceModel.Channels.ServiceChannelProxy+TaskCreator+<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
这是代码:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var address = new System.ServiceModel.EndpointAddress("soapendpoint");
var client = new Client(binding, address);
var cf = client.ChannelFactory;
cf.Credentials.UserName.UserName = username;
cf.Credentials.UserName.Password = password;
var channel = cf.CreateChannel();
var response = channel.GetPatientAsync();
我不是在寻求解决方案,而是一些关于我在这里做错了什么或者我应该尝试找出什么的指针?
【问题讨论】:
标签: .net wcf asp.net-core-3.1