Web services HTTP请求未经客户端身份验证方案';基本';。从服务器接收的身份验证标头为';基本领域=";

Web services HTTP请求未经客户端身份验证方案';基本';。从服务器接收的身份验证标头为';基本领域=";,web-services,wcf,wcf-binding,wcf-security,transport-security,Web Services,Wcf,Wcf Binding,Wcf Security,Transport Security,我正在尝试访问需要身份验证的Soap Web服务(HTTP)。我正在使用WCF使用该服务。我收到错误消息,因为HTTP请求未经客户端身份验证方案“Basic”授权。从服务器接收的身份验证标头为“Basic realm=“weblogic”” 非常感谢您的帮助,谢谢 这就是我的代码的样子: var binding = new BasicHttpBinding(); binding.MaxBufferSize = 2147483647;

我正在尝试访问需要身份验证的Soap Web服务(HTTP)。我正在使用WCF使用该服务。我收到错误消息,因为HTTP请求未经客户端身份验证方案“Basic”授权。从服务器接收的身份验证标头为“Basic realm=“weblogic””

非常感谢您的帮助,谢谢

这就是我的代码的样子:

var binding = new BasicHttpBinding();               
            binding.MaxBufferSize = 2147483647;

            binding.MaxReceivedMessageSize = 2147483647;
            binding.Security = new BasicHttpSecurity
            {
                Mode = BasicHttpSecurityMode.TransportCredentialOnly,
                Transport = new HttpTransportSecurity()
                {
                    ClientCredentialType = HttpClientCredentialType.Basic
                }
            };
            var endpoint = new System.ServiceModel.EndpointAddress(configuration["webserviceAddres"]);
            servicio = new ConsultaMontosOperadosFondosClient(binding, endpoint);
            servicio.ClientCredentials.UserName.Password = MyPass;
            servicio.ClientCredentials.UserName.UserName = MyUser;

如果服务不是通过https,那么尝试添加领域:(我不确定它是否是weblogic,只是根据您在错误中发布的内容)


在IIS身份验证模块中启用基本身份验证,然后提供用户名/密码

BasicHttpBinding binding = new BasicHttpBinding();
            binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient(binding, new EndpointAddress("http://10.157.13.69:8001/webservice1.asmx"));
            client.ClientCredentials.UserName.UserName = "administrator";
            client.ClientCredentials.UserName.Password = "abcd1234!";

如果问题仍然存在,请随时通知我。

HttpTransportSecurity()不包含领域的定义。我正在使用netcore 2。1@Clown123啊,好的,您是在使用.NETCore2.1生成用于调用web服务的代理类吗?代理类?你是指当你使用WCF或其他东西时生成的吗?@是的,如果你通过命令行或在project add service引用中使用svcutil,无论哪种方式,它都会生成用于调用服务的代理类和契约。是的,我就是这么做的。我添加了服务引用,它创建了proxys类。但它并没有自行设定领域,我也找不到设定的方法。
BasicHttpBinding binding = new BasicHttpBinding();
            binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            ServiceReference1.WebService1SoapClient client = new ServiceReference1.WebService1SoapClient(binding, new EndpointAddress("http://10.157.13.69:8001/webservice1.asmx"));
            client.ClientCredentials.UserName.UserName = "administrator";
            client.ClientCredentials.UserName.Password = "abcd1234!";