【发布时间】:2011-08-23 09:26:31
【问题描述】:
我在尝试使用网络服务时不断收到以下错误:
HTTP 请求未经客户端身份验证方案“基本”授权。从服务器收到的身份验证标头是“基本领域”。
Web 服务是使用 WCF 编写的 REST。身份验证是基于 https 的基本身份验证。
我们将不胜感激任何修复错误的帮助。
这是我试过的代码:
WebHttpBinding webBinding = new WebHttpBinding();
webBinding.Security.Mode = WebHttpSecurityMode.Transport;
webBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
ChannelFactory<ServiceReferences.BTService.FLDT_WholesaleService> factory = new ChannelFactory<ServiceReferences.BTService.FLDT_WholesaleService>(webBinding,
new EndpointAddress(
"https://wholesale.fluidata.co.uk/FLDT_BT_wholesale/Service.svc"));
factory.Endpoint.Behaviors.Add(new WebHttpBehavior());
factory.Credentials.UserName.UserName = "username";
factory.Credentials.UserName.Password = "password";
ServiceReferences.BTService.FLDT_WholesaleService proxy = factory.CreateChannel();
proxy.AvailabilityCheck("123");
【问题讨论】:
-
您是否在 IIS 上托管 REST 服务?
-
@Codo 是的。我在 IIS 中托管它
-
谁应该检查用户名和密码? IIS 还是 WFC 服务?
-
IIS。我确实通过浏览器中的端点检查了用户名和密码是否正确。