使用 Soap 客户端进行 Windows 身份验证的 Web 服务
我需要从 ac# 表单应用程序访问网络服务。
Web 服务需要 Windows 身份验证。
我使用以下代码:
ServiceDeskSoapClient sd = new ServiceDeskSoapClient();
sd.ClientCredentials.UserName.UserName = @"mydomain\myusername";
sd.ClientCredentials.UserName.Password = "mypassword";
sd.MyMethod();
但出现以下错误:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
如何正确设置凭据,以便它使用 Windows 身份验证,而不是匿名?
I need to access a webservice from a c# forms app.
The webservice needs Windows Authentication.
I use the following code:
ServiceDeskSoapClient sd = new ServiceDeskSoapClient();
sd.ClientCredentials.UserName.UserName = @"mydomain\myusername";
sd.ClientCredentials.UserName.Password = "mypassword";
sd.MyMethod();
But get the following error:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
How do I correctly set the credentials so it uses windows auth, not anonymous?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有人仍然需要这个,我今天很高兴找到它。这确实很简单:
In case anyone still needs this, I had the pleasure of figuring it out today. It really was quite simple:
在 <绑定> 中添加以下内容:客户端 app.config 中的部分:(
来自 http://morrisbahrami。 blogspot.com.au/2011/02/http-request-is-unauthorized-with.html)
Add the following inside the <binding> section in the client's app.config:
(from http://morrisbahrami.blogspot.com.au/2011/02/http-request-is-unauthorized-with.html)