Hi John,
If Anonymous access was turned off for the Web Service application,
requests are
required to provide credentials. By default calls to the proxy do not
inherit the
credentials of the caller. So if no credentials are explicitly being
supplied the request fails with 401, Access Denied.
#1. To set the credentials on the proxy before you make the call use
PROXY.Credentia ls = System.Net.Cred entialCache.Def aultCredentials
DefaultCredenti als represents the system credentials for the current
security context in which the application is running. For a client-side
application, these are usually the Windows credentials (user name,
password, and domain) of the user running the application. For ASP.NET
applications, the default credentials are the user credentials of the
identity for the asp worker process, or the user being impersonated.
#2. If you want to programly generate and set the Credential, you need to
use the System.Net.Netw orkCredential class and the
System.Net.Cred entialCache class. For example, here is a code snippet that
manually generate a Credential that use NTLM authentication type:
=============== =============== ======
private void btnCall_Click(o bject sender, System.EventArg s e)
{
//create webservice proxy
MyService.MySer vice ms = new AuthClient.MySe rvice.MyService ();
//create networkCredenti al
System.Net.Netw orkCredential nc = new System.Net.Netw orkCredential
("username","pa ssword","domain name");
System.Net.Cred entialCache cc = new System.Net.Cred entialCache();
//add into CredentialCache and speicfy the NTLM authType
cc.Add(new Uri(ms.Url),"NT LM",nc);
ms.Credentials = cc;
ms.Execute("dfd sfds");
}
=============== ===============
Is this the one you're looking for? If there is anything else unclear,
please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)