A server error in the "/callservice" application.
--------------------------------------------------------------------------------
Request failed for HTTP status 401: Unauthorized.
Note: An unhandled exception occurred during the execution of the current WEB request. Check the stack trace for more information about the error and where the error occurred in the code.
Exception Details: System.Net.WebException: Request failed for HTTP status 401: Unauthorized.
SOURCE Error:
Row Bayi: [System.Web.Services.Protocols.SoapDocumentMethodAttribute ("Http://tempuri.org/HelloWorld",
Requestnamespace= "http://tempuri.org/", responsenamespace= "http://tempuri.org/",
Use=system.web.services.description.soapbindinguse.literal,
parameterstyle=system.web.services.protocols.soapparameterstyle.wrapped)]
Line 82:public string HelloWorld () {
Row 83:object[] results = this. Invoke ("HelloWorld", new object[0]);
Row 84:return ((String) (Results[0]));
Line 85:}
Source file: D:\Cofco\CofcoMeeting\VSProjects\Cofco.Meeting\Cofco.Meeting.CallService\Web references\approveservice\ Reference.cs
Line: 83
Stack trace:
[WebException: Request failed for HTTP status 401: Unauthorized. ]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse (Soapclientmessage message, WebResponse response ,
Stream Responsestream, Boolean asynccall) +533199
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (String methodname, object[] parameters) +204
Cofco.Meeting.CallService.ApproveService.Service1.HelloWorld () in
D:\Cofco\CofcoMeeting\VSProjects\Cofco.Meeting\Cofco.Meeting.CallService\Web references\approveservice\ reference.cs:83
Cofco.meeting.callservice._default.btnhello_click (Object sender, EventArgs e) in
D:\cofco\cofcomeeting\vsprojects\cofco.meeting\cofco.meeting.callservice\default.aspx.cs:25
System.Web.UI.WebControls.Button.OnClick (EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent (String eventargument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (String eventargument) +7
System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourcecontrol, String eventargument) +11
System.Web.UI.Page.RaisePostBackEvent (NameValueCollection postdata) +33
System.Web.UI.Page.ProcessRequestMain (Boolean includestagesbeforeasyncpoint, Boolean includestagesafterasyncpoint ) +5102
--------------------------------------------------------------------------------
Version information: Microsoft. NET Framework Version: 2.0.50727.42; asp.net version: 2.0.50727.42
========================================================================================================
Solution 1
Set up your Web service in IIS to check anonymous access
Click Start, point to Administrative Tools, and then click Internet Information Services (IIS).
Expand your IIS server, right-click the WebService file that provides the service, and then click Properties.
In the Web Site Properties dialog box, click the Directory Security tab.
Under Authentication and access control, click Edit.
Click the Enable anonymous Access check box to select it.
Note: The user account in the User name box is used only for anonymous access through the Windows Guest account.
By default, the server creates and uses the account IUSR_computername. The anonymous user account password is used only in Windows, and the anonymous user does not log on with the username and password.
Under Authenticated access, click the Integrated Windows authentication check box to select it.
Click OK two times.
Solution 2
Approveservice.service1 ws1 = new Cofco.Meeting.CallService.ApproveService.Service1 ();
string str = String.Empty;
Ws1. URL = "Http://localhost/ApproveService/Service1.asmx";
Ws1. PreAuthenticate = true;s1. Credentials = system.net.credentialcache.defaultcredentials;//These two sentences are equally valid under Net 1.1 or 2.0
Ws1. useDefaultCredentials = True;//net 2.0 uses
str = ws1. HelloWorld ();
Lbmsg.text = str;