如题:在Winform程序中引用一个WebServices,调用其中的方法时,出现的错误提示如下
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'但是在Web程序中却没有问题,看起来是权限的问题。
在Web中是这样设置的:sr.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; (sr为Webservices中类的实例)
不知道各位XDJM有没有遇到此类情况的啊,你们是怎么解决的,更希望各位高手提些宝贵的意见,小弟感激不尽。谢谢。
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'但是在Web程序中却没有问题,看起来是权限的问题。
在Web中是这样设置的:sr.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; (sr为Webservices中类的实例)
不知道各位XDJM有没有遇到此类情况的啊,你们是怎么解决的,更希望各位高手提些宝贵的意见,小弟感激不尽。谢谢。
解决方案 »
- 各位大虾,请教关于控件重叠的问题
- win8应用调用web service的enValidateImage,在线等,立马结分。
- C# winform如何将数据信息写入网站的数据库ACCESS的
- 关于 ,,Request.ServerVariables["HTTP_ACCEPT"]
- DataTimePicker使用及日期段如何用sql语句插入数据表中
- DATATABLE
- 请问如何在PrintDocument中分别设置中文和英文字体?
- 送分呀,参与者有分!!!!!
- 本人的毕业设计中的两个问题,1.如何获取和设置richtext box 中光标的位置2.如何制作安装包.
- 如何生成几组不重复的数字?
- C#怎么制作绝对透明控件?
- C# 有没有自带的事务处理?
YourUpLoadServiceRef.WebServiceName ws= new YourUpLoadServiceRef.WebServiceName ();
// Create a new instance of CredentialCache.
CredentialCache credentialCache = new CredentialCache();
// Create a new instance of NetworkCredential using the client credentials.
NetworkCredential credentials = new NetworkCredential("windows登录用户名", "登录密码");
// Add the NetworkCredential to the CredentialCache.
credentialCache.Add(new Uri(math.Url), "NTLM", credentials);
// Add the CredentialCache to the proxy class credentials.
math.Credentials = credentialCache;
// Call the method on the proxy class.
string Str = math.HelloWorld("keycom");//基本身份验证:
YourUpLoadServiceRef.WebServiceName ws= new YourUpLoadServiceRef.WebServiceName ();
ws.Credentials = new System.Net.NetworkCredential("windows登录用户名", "登录密码");