The client proxies generated by the WebServiceUtil.exe utility will support three authentication schemes in the current release: Basic, Digest and NTLM.
NTLM authentication is handled automatically by the calling proxy, with the credentials of the calling thread being supplied to the remote web service. The proxy consumer setting the UserName and Password properties on the proxy instance handles basic and Digest authentication scenarios. These are then transmitted as appropriate to the remote web service.
If a URI expects the client to be authenticated, but the UserName, Password and Domain properties are not set, then accessing the service will fail and a WebException indicating a 401 auth error will be thrown.
For example, the below sample demonstrates how to utilize the proxy’s authentication services:
DataSet msftDetails; Investor investorService = new Investor(); investorService.UserName = “MyName”; investorService.Password = “MyPassword”; investorSerrvice.Domain = “MyDomain”; msftDetails = investorService.GetStockDetails(“MSFT”);