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.Credentials = System.Net.CredentialCache.DefaultCredentials
DefaultCredentials 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.NetworkCredential class and the
System.Net.CredentialCache class. For example, here is a code snippet that
manually generate a Credential that use NTLM authentication type:
====================================
private void btnCall_Click(object sender, System.EventArgs e)
{
//create webservice proxy
MyService.MyService ms = new AuthClient.MyService.MyService();
//create networkCredential
System.Net.NetworkCredential nc = new System.Net.NetworkCredential
("username","password","domainname");
System.Net.CredentialCache cc = new System.Net.CredentialCache();
//add into CredentialCache and speicfy the NTLM authType
cc.Add(new Uri(ms.Url),"NTLM",nc);
ms.Credentials = cc;
ms.Execute("dfdsfds");
}
==============================
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.)