我使用以下代码创建频道:
var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
basicHttpBinding.Security.Transport.Realm = "TeamCity";
var channelFactory = ChannelFactory<IMyInterface>(basicHttpBinding);
channelFactory.EndPint.Address = new EndPoint("http://localhost/httpAuth/app/rest/version");
channelFactory.Credentials.Username.Username = 'username';
channelFactory.Credentials.Username.Password = 'password';
channelFactory.Open();
var channel = channel.CreateChannel();
var verInfo = channel.GetVersion();
但是当我运行此代码时,CLR引发“远程服务器返回了意外响应:(405方法不允许)” 如何使用wcf进行基本的http身份验证?