我不确定这是否是答案,但我们可以将其称为支持材料。
我有来自 msdn 的代码示例,它展示了如何通过创建服务客户端并将给定报告作为 PDF 调用并将其保存到文件流来实现此目的。
http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx
我当前遇到的问题是在将 VS 指向 SSRS 服务后找到正确的客户端对象进行交互。我用来与服务交互的对象是:
ReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient();
但是,该界面与我的代码示例不匹配。所以这有点接近,但不是答案。
更新:正确的代理类生成器
这是如何正确生成代理的链接。您需要安装 Windows sdk(当前版本是 7.1)。您可以像我一样在 microsoft.com 上找到它。执行命令行,它会为您生成一个文件。包含在项目中:
http://msdn.microsoft.com/en-us/library/ms155134%28v=SQL.110%29.aspx http://msdn.microsoft.com/en-us/library/ms155134%28v=SQL.110%29.aspx
更新:一切正常
我只需要生成正确的代理即可。好的,对于 SSRS 2010,显然他们将报告执行和管理分为两个服务。从 C# 控制台应用程序生成报告所需的唯一服务是执行服务。也许这对除了我之外的每个人来说都是显而易见的:)?
好的,打开一个 Windows SDK 命令 shell 并将这些内容放入其中以用于执行服务:
wsdl /language:CS /n:"Microsoft.SqlServer.ReportExecution" http://<Server Name>/reportserver/reportexecution2010.asmx?wsdl /o:"ReportExecution.cs"
转到 C:\Program Files\Microsoft SDKs\Windows\v7.1 并选择 ReportExecution.cs 文件。将其复制并粘贴到您的项目中。
那么你只需要这样说:
Microsoft.SqlServer.ReportExecution.ReportExecutionService rsExec =
new Microsoft.SqlServer.ReportExecution.ReportExecutionService();
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Url = @"http://<ServerName>/reportserver/ReportExecution2005.asmx";
按照以下示例进行操作这个链接 http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx,与上面的报告相同,您应该从您方便的 C# 应用程序生成一些非常棒的报告。