WebService Authorization - The request failed with HTTP status 401: Unauthorized.
-
Hello. Here is my situation. I'm building a client asp.net application that will reside on our DMZ. I have a web service (called "ServiceBus") that acts as a single access point through a single port to our data center. The ServiceBus has methods that do several tasks such as fetching data, running SSRS reports, streaming documents, etc. Everything works fine when testing my client app from within the domain but from the DMZ I get authorization errors (see subject line). The following line of code will get me to the HelloWorld method but any other method that fetches anything from another server fails with permission errors:
serviceproxy.Credentials = System.Net.CredentialCache.DefaultCredentials
So it seems that I need to send domain user credentials which I try below. I have IIS security set to Digest. The code below was suggested on this post: http://forums.asp.net/p/1050587/1862246.aspx#1862246Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim serviceproxy As New WSBus.ServicesBusWebService() Dim userCredential As NetworkCredential = New NetworkCredential("username", "password", "domain") Dim credentials As CredentialCache = New CredentialCache() credentials.Add(New Uri(serviceproxy.Url), "Digest", userCredential) serviceproxy.Credentials = credentials serviceproxy.PreAuthenticate = True Dim response = serviceproxy.HelloWorld() 'BREAKS HERE lblMessage.Text = response End Sub
Any help will be greatly appreciated!