调用需要进行身份验证的Web Service
以调用SQL 2005的Reporting Service为例, 此Web Service需要进行windows身份验证:
string userName = "admin"; string password = "1"; string domain = "TestDomain"; // ReportingService 是 Web Service的代理类 // ConfigurationSettings.AppSettings["RptServer"] web.config中读取web servcie的地址,如:http://ReportService/ReportService.asmx ReportingService rs = new ReportingService(ConfigurationSettings.AppSettings["RptServer"]); // 设置Credentials rs.Credentials = new System.Net.NetworkCredential(userName, password, domain); // 调用Web Service的Render方法 rs.Render();