呃。我在回复自己,希望有人可以借鉴:
我最终做到了,使用 here 和 here 所述的 Reporting Services Web 服务。这里要记住的一点是,服务的名称已更改(我相信从 SQL Server 2005 起)端点是 ReportService2005.asmx。
添加网络参考后,我仍然遇到各种问题。总而言之,这是最终为我工作的代码(注意:我在域中,我连接的 IIS 需要域窗口身份验证)。
ReportParameter[] parameters;
const string historyId = null;
const bool forRendering = true;
ParameterValue[] values = null;
DataSourceCredentials[] credentials = new DataSourceCredentials[] {};
ReportingService2005SoapClient c = new ReportingService2005SoapClient();
c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("USERNAME", "PASSWORD", "DOMAIN");
c.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
c.GetReportParameters
(
"/CycleStatus/Builds Score",
historyId,
forRendering,
values,
credentials,
out parameters
);
但是,我被以下错误所困扰:
“HTTP 请求未通过客户端身份验证方案‘匿名’进行授权。从服务器接收到的身份验证标头为‘Negotiate,NTLM’”
要处理您需要更改的问题,请在 app.config 中更改安全节点,如下所示:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
之后一切正常。