試圖消耗WebService時,我不斷收到以下錯誤:WCF REST消費誤差
HTTP請求是未經授權的客戶端身份驗證方案「基本」。從服務器收到的身份驗證頭是'Basic Realm'。
該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
@Codo是的。我在IIS中託管它 –
誰應該檢查用戶名和密碼? IIS或WFC服務? – Codo