I have an ASMX web service (on my localhost - WinXP IIS 5.1) that I call from a webclient. My webservice must consume another ASMX web service (on a Win 2003 server IIS 6.0).
When I provide credentials in my webservice code in a "hard-coded" manner:
engineWSE.Credentials = new System.Net.NetworkCredential("myUser", "myPass", "myDomain");
...the subsequent invoke of the remote web service works fine.
Now I am trying to impersonate myself in some initial testing. My initial reading on this tells me this can be a big subject but here is what I've done for starters:
UNCHECKED "Anonymous access" in my virtual directory for the WebClient site on my localhost
in web.config of my webclient site, I established: authentication mode="Windows" and identity impersonate="true"
in the webmethod of my webservice that has to call the remote service, I changed to:
engineWSE.Credentials = System.Net.CredentialCache.DefaultCredentials;
When the remote webservice gets invoked with these DefaultCredentials, I get the following error:
System.Web.Services System.Web.Services.Protocols.SoapException: Server was unable to process request.--->
System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
at 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)
I am not sure whether I have misunderstood and tried to over-simplify "Impersonation" or whether the remote webservice is somehow wired to only accept credentials with 3 arguments (i.e. username, password, domain).