Asp.net Webservice 401 Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss 401 unauthorized web service call the workings and policies of this site About Us Learn more 401 unauthorized web service java about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack web service access denied Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping [iss.0088.9164] access to wsdescriptor denied each other. Join them; it only takes a minute: Sign up Error calling web service 401: Unauthorized up vote 2 down vote favorite 1 I get The request failed with HTTP status 401: Unauthorized My web service is .NET 4 running on IIS6. My client is .NET 2 running on IIS6 When I run the both client and
401 Unauthorized Error Web Service
serivce on my local host it works. When I move the service to the web server I get the above error. I have set Allow An I have tried every combination of anonymous access & integrated Windows authentication within IIS I can access the web service via a brower and call it using Web Service Studio ok, it just does not work when I call from another .NET service UPDATE I have checked that the IUSR account has NTFS file permissions and is also added in local security policy as a USER that can access the server over network. When I call from WebService Studio it makes two request first called gets back 401, then it calls again passing 'Authorization' and works. See below. So for some reason my anonymous access is not working. As when I only have anonymous access ticked and integrated Windows authentication unticked I cannot even access it from the brower Content-Type: text/xml; charset=utf-8 SOAPAction: "http://tempuri.org/HelloWorld" Host: webdev1 Content-Length: 314 Expect: 100-continue Connection: Keep-Alive
Today I've spent almost the whole day to figure out why an application (COM+)
couldn't authenticate against a ASMX web service. Using my favorite networking 401 unauthorized access web service tools Wireshark and HTTP Fiddler I saw that the credentials didn't get included in the the request failed with http status 401: unauthorized initial request, and no other request was made when the 401 challenge came from the web service. The code was doing something like this: using (client http://stackoverflow.com/questions/11241516/error-calling-web-service-401-unauthorized = new MyWebService()) { var credentials = new NetworkCredential(); credentials.Username = ConfigurationManager.AppSettings["WSUserName"] credentials.Password = ConfigurationManager.AppSettings["WSPassword"] credentials.Domain = ConfigurationManager.AppSettings["WSDomain"] client.Credentials = credentials; // .. and the call here .. } That didn't work very well. So I fiddled around with CredentialsCache (trying both "Negotiate" and "NTLM") and using FQDN or just the http://blog.gauffin.org/2012/12/solved-getting-401-unauthorized-while-calling-an-asmx-service-using-windows-authentication/ server name: var cache = new System.Net.CredentialCache(); cache.Add(new Uri("http://srt00428"), "NTLM", new NetworkCredential("SomeName", "SomePassword")); var client = new MyWebService(); client.Credentials = cache; // ..and the call.. That didn't work so well either. Then I tried to assign it directly: var client = new MyWebService(); client.Credentials = new NetworkCredential("SomeName", "SomePassword", "MyDomain") // ..and the call.. Didn't work either. And out of desperation I just tried to use the username/password: var client = new MyWebService(); client.Credentials = new NetworkCredential("SomeName", "SomePassword") // ..and the call.. Voila! It worked. Don't ask me why, but it does. Do note that I couldn't get this to work: using (client = new MyWebService()) { var credentials = new NetworkCredential(); credentials.Username = ConfigurationManager.AppSettings["WSUserName"] credentials.Password = ConfigurationManager.AppSettings["WSPassword"] client.Credentials = credentials; // .. and the call here .. } The username/password HAS to be set in the NetworkCredential constructor.. My final code: using (client = new MyWebService()) { var username = ConfigurationManager.AppSettings["WSUserName"] var
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: 401 Unauthorized https://social.msdn.microsoft.com/Forums/sqlserver/en-US/2b28272c-e668-41c9-80ce-af4d6eadca61/401-unauthorized-only-when-using-web-service-from-aspnet-application?forum=sqlreportingservices only when using web service from ASP.NET application SQL Server > SQL Server Reporting Services, Power View Question 0 Sign in to vote I have an http://forums.iis.net/t/1149741.aspx?Intermittently+getting+401+Access+Denied+with+Web+Service ASP.NETweb application on one server trying to access a report server on another. When the web application tries to take any action through the web service, it web service receives a "401: Unauthorized" error. Both servers use Windows Server 2008, the SQL Server is running SQL 2008 (SP1). Both servers are on the same domain,but authentication is set up through a local account defined on the SQL machine (local Windows user, using Windows authentication). I can successfully access the //server/reports and //server/reportserver 401 unauthorized web sites from the app server using Internet Explorerwith the credentials set up on the sql server. I can successfully authenticate & browse to //server/reportserver/reportservice2005.asmxand see the wsdl file. The problem only exists when the web app itself tries to use the SSRS web service endpoint. Kerberos is set up, but not being used for this exchange. Here is asimplified version of my code trying to do the exchange that fails with "401: Unauthorized": ReportingService2005 rs = new ReportingService2005(); rs.Url = "http://server/reportserver/reportservice2005.asmx"; CredentialCache cache = new CredentialCache(); cache.Add( new Uri(rs.Url), "Negotiate", new NetworkCredential("user", "password", "domain" )); //cache.Add( new Uri(rs.Url), "Negotiate", new NetworkCredential("user", "password")); //cache.Add( new Uri(rs.Url), "Negotiate", new NetworkCredential("domain/user", "password")); rs.Credentials = cache; SearchCondition condition = new SearchCondition(); condition.Condition = ConditionEnum.Equals; condition.ConditionSpecified = true; condition.Name = "Name"; condition.Value = folder; SearchCondition[] conditions = new SearchCondition[1]; conditions[0] = condition; CatalogItem[] items = null; items = rs.FindItems( "/", BooleanOperatorEnum.Or, conditions ); This code works fine on several other simila
Web Platform Installer Get Help: Ask a Question in our Forums More Help Resources Blogs Forums Home IIS.NET Forums IIS 5 & IIS 6 Security Intermittently getting 401: Access Denied with Web Service Intermittently getting 401: Access Denied with Web Service [Answered]RSS 10 replies Last post Jun 09, 2008 09:24 AM by tomkmvp ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Advanced Search Reply joker77 21 Posts Intermittently getting 401: Access Denied with Web Service Jun 06, 2008 05:22 AM|joker77|LINK Hi there, I have an ASP.NET Web Service project on my local machine, and I intermittently get the following error while trying to access it from another .NET project: "The request failed with HTTP status 401: Access Denied." I don't get this all the time, only sometimes, and if I reboot then I can access the web service again for a couple of hours until it happens again. I have no idea why this would be happening. I have Anonymous Access turned on in IIS on the web service directory (allowing IIS to control the password), I've also allowed for Integrated Windows Authentication. Any thoughts on why I keep having this problem? Are my security settings correct? At the moment I'm still developing the projects, my machine is being used as the test machine. Reply Rovastar 4721 Posts MVPModerator Re: Intermittently getting 401: Access Denied with Web Service Jun 06, 2008 05:48 AM|Rovastar|LINK Have a look at your IIS logs to find out what sub code is for the 401 error ' 401 - Access denied. IIS defines several different 401 errors that indicate a more specific cause of the error. These specific error codes are displayed in the browser but are not displayed in the IIS log: • 401.1 - Logon failed. • 401.2 - Logon failed due to server configuration. • 401.3 - Unauthorized due to ACL on resource. • 401.4 - Authorization failed by filter. • 401.5 - Authorization fai