Calling web service from asp.net page fails
|
| Calling web service from asp.net page fails | Hi all,
I'm trying to call a web service from an asp.net (v1.1) page written in C# (the web service was written in C# too) and I keep getting a "The request failed with HTTP status 401: Unauthorized. " error message. Calling the web service works fine when I create a windows form application to call it. The IIS is on a win2003 server and it is configured to use "Integrated Authentication".
The IIS logs do not show a userid from the asp.net call to the webservice, they do show a userid from the windows form app. I suspect that this is the issue.
The first portion of the stack trace is "System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)" ... the rest is the lines within my .net application.
I have added CredentialCache.DefaultCredentials() and then tried it. I have also tried supplying user/pwd/domain with the same error results.
Does anybody have any ideas as to what may be causing this and how to resolved it? Any ideas on what parameters to use/fill that I am not?
The relevant part of my code is:
mxService mxAs = new mxService(); mxAs.Url = _webServer + _serviceUrl; CredentialCache crCache = new CredentialCache(); NetworkCredential netCr = new NetworkCredential(); netCr.Domain = "ourDomain"; netCr.UserName = "user1"; netCr.Password = "123"; crCache.Add(new Uri(mxAs.Url), "Negotiate", netCr ); mxAs.Credentials = crCache; string listings = mxAs.getListings("News","Approved"); // 401 - Not Authorized here...
Thanks & regards Jon
| | Thank's Paul,
The server that is hosting the web service is using "Windows" authentication and when I added in "Basic" authentication it works fine. What I am wondering is if this is a case of to many 'hops' or a quick pass through of the firewall rules within our network. I will now need to discuss this with our network people to determine if this is an acceptable way to go.
Thanks & regards Jon
|
|
|
|
|
 | Members Area | |
|
 | Last Web Marketing |
|
|
|
|
 | Last Programming Tips |
|
|
|
|
 | Last News |
|
|
|
|
|
|