我一直在研究 SQL Server Reporting Services 2008,我正在使用以下代码从 asp.net 连接到报表服务器:
ReportExecutionService rs = new ReportExecutionService();
System.Net.CredentialCache.DefaultNetworkCredentials.Domain = ConfigurationManager.AppSettings["Domain"].ToString();
System.Net.CredentialCache.DefaultNetworkCredentials.UserName = ConfigurationManager.AppSettings["UserName"].ToString();
System.Net.CredentialCache.DefaultNetworkCredentials.Password = ConfigurationManager.AppSettings["Password"].ToString();
rs.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
// Render arguments
byte[] result = null;
string reportpath = reportPath;
string format = "PDF";
string historyID = null;
string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
string encoding;
string mimeType;
string extension;
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = reportParameterBidName.Trim();
parameters[0].Value = reportParameterBidValue.Trim();
Warning[] warnings = null;
string[] streamIDs = null;
ExecutionInfo execInfo = new ExecutionInfo();
ExecutionHeader execHeader = new ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportpath, historyID);
rs.SetExecutionParameters(parameters, "en-us");
String SessionId = rs.ExecutionHeaderValue.ExecutionID;
try
{
result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
return result;
}
catch (SoapException e)
{
return null;
}
现在它适用于我的本地服务器,当我将它上传到最终服务器时它不起作用并引发无法连接错误。如果我使用 VPN 并使用相同的凭据,那么它也可以正常工作。
请就此提出建议。