我是靠谱客的博主 美丽背包,最近开发中收集的这篇文章主要介绍调用webservice时报错The request failed with HTTP status 401: Access Denied. 的解决方案。,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Note: This is KB article is taken from MSDN as it is for my own reference.
SYMPTOMS
1. | Create a new ASP.NET Web Service by using Visual C# .NET or Visual Basic .NET. | ||||||||||||||||||||
2. | Name the project WebServiceTest. | ||||||||||||||||||||
3. | By default, Service1.asmx is created. | ||||||||||||||||||||
4. | Uncomment the default WebMethod "HelloWorld()". | ||||||||||||||||||||
5. | On Build menu, click Build Solution. | ||||||||||||||||||||
6. | Turn off Anonymous access to WebServiceTest. To do this, follow these steps:
| ||||||||||||||||||||
7. | On the Build menu, click Build Solution. | ||||||||||||||||||||
8. | Type the following address in the browser to view the Service1 Web service description:
http://localhost/WebServiceTest/Service1.asmx
| ||||||||||||||||||||
9. | Test the HelloWorld WebMethod. The WebMethod works as expected. | ||||||||||||||||||||
10. | Add a Web Reference to a test ASP.NET Web Application. To do this, follow these steps:
| ||||||||||||||||||||
11. | In Solution Explorer, right-click WebForm1.aspx, and then click View Code. | ||||||||||||||||||||
12. | Append the following code to the Page_Load event: Visual C# .NET Sample: Visual Basic .NET Sample: | ||||||||||||||||||||
13. | On the Debug menu, click Start, and then view the application in the browser. | ||||||||||||||||||||
14. | The error message that is discussed in the "Symptoms" section appears in the browser. | ||||||||||||||||||||
15. | To resolve this problem, assign DefaultCredentials to the Credentials property of the Web service client-side proxy. To do this, insert the following code before the line "Response.Write( myProxy.HelloWorld())": Visual C# .NET Sample: Visual Basic .NET Sample: | ||||||||||||||||||||
16. | Repeat step 13 |
最后
以上就是美丽背包为你收集整理的调用webservice时报错The request failed with HTTP status 401: Access Denied. 的解决方案。的全部内容,希望文章能够帮你解决调用webservice时报错The request failed with HTTP status 401: Access Denied. 的解决方案。所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复