5

我正在使用 SSRS 2008(不是 R2)

我有一个部署到开发服务器的报告,我试图通过调用执行服务将报告呈现为 pdf。

我得到的错误是以本机模式运行的报表服务器不支持此操作。---> Microsoft.ReportingServices.Diagnostics.Utilities.OperationNotSupportedNativeModeException:在本机模式下运行的报表服务器不支持此操作。

我注意到两件事:一是 Web 服务 wsdl 显示 LoadReport 有两个参数 - 报告路径和历史 ID,但是当我为 ReportExecution2005.asmx 生成服务引用时,LoadReport 方法有 5 个参数:trusteduserheader、reportPath、historyid、serviceinfoheader , 和执行头

我尝试在 url 末尾添加带有和不带有 ?wsdl 的服务引用,但结果是一样的

这是我正在使用的代码:

ReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient("ReportExecutionServiceSoap", "http://xxx:80/ReportServer/ReportExecution2005.asmx");            
        rs.ClientCredentials.Windows.ClientCredential = new NetworkCredential("aaa", "aaa", "aaa"); 

        rs.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;



 // Render arguments

    byte[] result = null;
    string reportPath = "/Invoices/InvoiceStandard";
    string format = "PDF";
    string historyID = null;
    string devInfo = "";

    // Prepare report parameter.

    ParameterValue[] parameters = new ParameterValue[3];

    parameters[0] = new ParameterValue();
    parameters[0].Name = "PartyID";
    parameters[0].Value = "19758";
    parameters[1] = new ParameterValue();
    parameters[1].Name = "Contract";
    parameters[1].Value = "17703"; // June
    parameters[2] = new ParameterValue();
    parameters[2].Name = "FinancialPeriod";
    parameters[2].Value = "MAR-2012";
    string encoding="";
    string mimeType="";
    string extension="";
    Warning[] warnings = null;
    string[] streamIDs = null;

    ExecutionInfo execInfo = new ExecutionInfo();
    TrustedUserHeader trusteduserHeader = new TrustedUserHeader();
    ExecutionHeader execHeader = new ExecutionHeader();
    ServerInfoHeader serviceInfo = new ServerInfoHeader();


    execHeader = rs.LoadReport(trusteduserHeader, reportPath, historyID, out serviceInfo, out execInfo);

    rs.SetExecutionParameters(execHeader, trusteduserHeader, parameters, "en-us", out execInfo);

    try
    {                
        rs.Render(execHeader,
                    trusteduserHeader,
                    format, 
                    devInfo, 
                    out result,
                    out extension, 
                    out encoding, 
                    out mimeType, 
                    out warnings, 
                    out streamIDs);
    }

这是我的 web.config

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="ReportExecutionServiceSoap" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows"/>
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://xxx:80/ReportServer/ReportExecution2005.asmx"
        binding="basicHttpBinding" bindingConfiguration="ReportExecutionServiceSoap"
        contract="SSRS.ReportExecutionServiceSoap" name="ReportExecutionServiceSoap" />
    </client>
  </system.serviceModel>
</configuration>
4

2 回答 2

11

我在使用 SSRS 2008 R2 时遇到了同样的问题,但我不想求助于调用报表查看器控件。

上面,Rick Hodder 使用了以下语句:

TrustedUserHeader trusteduserHeader = new TrustedUserHeader();

OperationNotSupportedNativeModeException如果 SSRS 安装未配置 SSL 连接证书,此语句将导致他遇到的错误。检查 SSRS 日志以获取包含以下内容的错误条目:

错误:本机模式不支持 TrustedHeader。

如果是这种情况,您需要将服务器配置为使用 SSL,或者将 null 用于受信任的标头。

TrustedUserHeader trusteduserHeader = null;
于 2015-08-24T18:09:37.060 回答
0

该报告是从某个前端加载的还是从 DLL 加载的?对我来说,您似乎正在使用 ASP.net 应用程序。在这种情况下,您可以使用 reportViewer 对象为您提取报告,所有繁重的工作都可以由 ReportViewer 完成,然后您可以使用类似这样的方式将文件保存为 PDF

 reportViewer.ServerReport.ReportServerUrl = new Uri(Config.ReportServerURL);
 reportViewer.ServerReport.ReportPath = String.Format("{0}/{1}", Config.ReportServerEnvironment, reportName);
 reportViewer.ServerReport.ReportServerCredentials = new ReportsCredentials(Config.ReportServerUser, Config.ReportServerPassword, Config.ReportServerDomain);

reportViewer.GetDocumentStream(SSRSFormatType.Pdf, documentName);

这里的 reportViewer 是对屏幕上 ReportViewer 对象的引用。

于 2012-06-08T07:46:49.143 回答