我们正在连接到关闭匿名访问、打开 Windows 身份验证的 WCF Web 服务。web.config 文件有一个本地用户帐户,用于允许用户和拒绝用户=“?”。
我可以很好地下载和生成服务代理(被提示输入凭据),但是从我的 Windows 窗体项目(即使在传递凭据时),我收到以下错误:
System.ServiceModel.Security.MessageSecurityException was unhandled
Message="The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Basic realm=\"SEIPART001\"'."
Message="The remote server returned an error: (401) Unauthorized."
这是我的示例代码:
ip.eIPCShoppingCartWSSoapClient client = new iParts.ip.eIPCShoppingCartWSSoapClient();
System.Net.NetworkCredential creds = new System.Net.NetworkCredential("username", "password", "domain");
client.ClientCredentials.Windows.ClientCredential = creds;
iParts.ip.OrderListItem[] listItem = client.GetOrderList("1234"); //throws exception here