Condividi tramite


ReportExecutionService.Render Method

Processes a specific report and renders it in the specified format.

Spazio dei nomi: Microsoft.WSSUX.ReportingServicesWebService.RSExecutionService2005
Assembly : ReportExecution2005 (in reportexecutionservice.dll)

Sintassi

'Dichiarazione
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace:="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace:="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
<SoapHeaderAttribute("ServerInfoHeaderValue", Direction:=SoapHeaderDirection.Out)> _
<SoapHeaderAttribute("ExecutionHeaderValue")> _
Public Function Render ( _
    Format As String, _
    DeviceInfo As String, _
    <OutAttribute> ByRef Extension As String, _
    <OutAttribute> ByRef MimeType As String, _
    <OutAttribute> ByRef Encoding As String, _
    <OutAttribute> ByRef Warnings As Warning(), _
    <OutAttribute> ByRef StreamIds As String() _
) As Byte()
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
[SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out)] 
[SoapHeaderAttribute("ExecutionHeaderValue")] 
public byte[] Render (
    string Format,
    string DeviceInfo,
    out string Extension,
    out string MimeType,
    out string Encoding,
    out Warning[] Warnings,
    out string[] StreamIds
)
[SoapDocumentMethodAttribute(L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace=L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace=L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse::Literal, ParameterStyle=SoapParameterStyle::Wrapped)] 
[SoapHeaderAttribute(L"ServerInfoHeaderValue", Direction=SoapHeaderDirection::Out)] 
[SoapHeaderAttribute(L"ExecutionHeaderValue")] 
public:
array<unsigned char>^ Render (
    String^ Format, 
    String^ DeviceInfo, 
    [OutAttribute] String^% Extension, 
    [OutAttribute] String^% MimeType, 
    [OutAttribute] String^% Encoding, 
    [OutAttribute] array<Warning^>^% Warnings, 
    [OutAttribute] array<String^>^% StreamIds
)
/** @attribute SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped) */ 
/** @attribute SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out) */ 
/** @attribute SoapHeaderAttribute("ExecutionHeaderValue") */ 
public byte[] Render (
    String Format, 
    String DeviceInfo, 
    /** @attribute OutAttribute() */ /** @ref */ String Extension, 
    /** @attribute OutAttribute() */ /** @ref */ String MimeType, 
    /** @attribute OutAttribute() */ /** @ref */ String Encoding, 
    /** @attribute OutAttribute() */ /** @ref */ Warning[] Warnings, 
    /** @attribute OutAttribute() */ /** @ref */ String[] StreamIds
)
JScript non supporta il passaggio di argomenti di tipo valore per riferimento.

Parametri

  • Format
    The format in which to render the report. This argument maps to a rendering extension. Supported extensions include XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC. A list of supported extensions may be obtained by calling the ListRenderingExtensions method.
  • DeviceInfo
    An XML string that contains the device-specific content that is required by the rendering extension specified in the Format parameter. DeviceInfo settings must be passed as internal elements of a DeviceInfo XML element. For more information about device information settings for specific output formats, see Reporting Services Device Information Settings.
  • Extension
    [out] The file extension corresponding to the output stream
  • MimeType
    [out] The MIME type of the rendered report.
  • Encoding
    [out] The encoding used when report server renders the contents of the report.
  • Warnings
    [out] An array of Warning objects that describes any warnings that occurred during report processing.
  • StreamIds
    [out] The stream identifiers. These IDs are passed to the RenderStream method. You can use them to render the external resources (images, etc.) that are associated with a given report.

Valore restituito

A Byte[] array of the report in the specified format.

Osservazioni

Render renders a processed report associated with the report execution identified in the ExecutionInfo header. If no session snapshot exists, this method will execute the report (if all credential and parameter requirements are met), resulting in a new session snapshot being created. If the report needs to be reprocessed because non-query parameter values have changed, the snapshot will be reprocessed.

If the execution options are set to cache or execution snapshot, the call to Render may use an existing snapshot.

If the report is set to cache and the supplied parameter values and credentials match, the cached copy of the snapshot may be loaded instead of actually processing the report.

If credential and parameter requirements are not met, this method will return an error.

Subsequent calls to Render can be used to fetch additional pages of the report if the rendering extension supports specifying multiple pages.

A limitation of the Render method is that the output cannot be streamed, so the entire file must be in-memory.

Please see Identifying Execution State for a discussion of the execution life cycle, which includes a description of the steps necessary to load and render a report.

Esempio

To compile the following code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see Compilazione ed esecuzione degli esempi di codice. The following code example renders a report in MHTML and saves it as an .mht file to disk.

Imports System
Imports System.IO
Imports System.Web.Services.Protocols
Imports myNamespace.MyReferenceName

Class Sample
    Public Shared Sub Main()
        Dim rs As New ReportExecutionService()
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials
        rs.Url = "http://myserver/reportserver/ReportExecution2005.asmx"

        ' Render arguments
        Dim result As Byte() = Nothing
        Dim reportPath As String = "/AdventureWorks Sample Reports/Employee Sales Summary "
        Dim format As String = "MHTML"
        Dim historyID As String = Nothing
        Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"

        ' Prepare report parameter.
        Dim parameters(2) As ParameterValue

        parameters(0) = New ParameterValue()
        parameters(0).Name = "EmpID"
        parameters(0).Value = "288"
        parameters(1) = New ParameterValue()
        parameters(1).Name = "ReportMonth"
        parameters(1).Value = "6" ' June
        parameters(2) = New ParameterValue()
        parameters(2).Name = "ReportYear"
        parameters(2).Value = "2004"

        Dim credentials As DataSourceCredentials() = Nothing
        Dim showHideToggle As String = Nothing
        Dim encoding As String = ""
        Dim mimeType As String = ""
        Dim warnings As Warning() = Nothing
        Dim reportHistoryParameters As ParameterValue() = Nothing
        Dim streamIDs As String() = Nothing

        Dim execInfo As New ExecutionInfo
        Dim execHeader As New ExecutionHeader()
        Dim SessionId As String
        Dim extension As String = ""

        rs.ExecutionHeaderValue = execHeader

        execInfo = rs.LoadReport(reportPath, historyID)

        rs.SetExecutionParameters(parameters, "en-us")

        SessionId = rs.ExecutionHeaderValue.ExecutionID
        Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)


        Try
            result = rs.Render(format, devInfo, extension, _
               encoding, mimeType, warnings, streamIDs)

            execInfo = rs.GetExecutionInfo()

            Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)


        Catch e As SoapException
            Console.WriteLine(e.Detail.OuterXml)
        End Try

        ' Write the contents of the report to an MHTML file.
        Try
            Dim stream As FileStream = File.Create("report.mht", result.Length)
            Console.WriteLine("File created.")
            stream.Write(result, 0, result.Length)
            Console.WriteLine("Result written to the file.")
            stream.Close()
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub 'Main
End Class
using System;
using System.IO;
using System.Web.Services.Protocols;
using myNamespace.MyReferenceName;

class Sample
{
    static void Main(string[] args)
    {
        ReportExecutionService rs = new ReportExecutionService();
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        rs.Url = "http://myserver/reportserver/ReportExecution2005.asmx";

        // Render arguments
        byte[] result = null;
        string reportPath = "/AdventureWorks Sample Reports/Employee Sales Summary";
        string format = "MHTML";
        string historyID = null;
        string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

        // Prepare report parameter.
        ParameterValue[] parameters = new ParameterValue[3];
        parameters[0] = new ParameterValue();
        parameters[0].Name = "EmpID";
        parameters[0].Value = "288";
        parameters[1] = new ParameterValue();
        parameters[1].Name = "ReportMonth";
        parameters[1].Value = "6"; // June
        parameters[2] = new ParameterValue();
        parameters[2].Name = "ReportYear";
        parameters[2].Value = "2004";

        DataSourceCredentials[] credentials = null;
        string showHideToggle = null;
        string encoding;
        string mimeType;
        string extension;
        Warning[] warnings = null;
        ParameterValue[] reportHistoryParameters = 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;

        Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID);


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

            execInfo = rs.GetExecutionInfo();

            Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime);


        }
        catch (SoapException e)
        {
            Console.WriteLine(e.Detail.OuterXml);
        }
        // Write the contents of the report to an MHTML file.
        try
        {
            FileStream stream = File.Create("report.mht", result.Length);
            Console.WriteLine("File created.");
            stream.Write(result, 0, result.Length);
            Console.WriteLine("Result written to the file.");
            stream.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }

    }
}

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Piattaforme

Piattaforme di sviluppo

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Piattaforme di destinazione

Per un elenco delle piattaforme supportate, vedere Requisiti hardware e software per l'Installazione di SQL Server 2005.

Vedere anche

Riferimento

ReportExecutionService Class
ReportExecutionService Members
Microsoft.WSSUX.ReportingServicesWebService.RSExecutionService2005 Namespace