Compartir a través de


Lección 1: Creación del proyecto de Visual Studio de esquema RDL

En este tutorial, creará una aplicación de consola sencilla. En este tutorial se da por supuesto que está desarrollando en Microsoft Visual Studio 2010.

Nota:

Al acceder al servicio web del servidor de informes que se ejecuta en SQL Server Express con Advanced Services, debe agregar "_SQLExpress" a la ruta "ReportServer". Por ejemplo:

http://myserver/reportserver_sqlexpress/reportservice2010.asmx"

Para crear el proxy del servicio web

  1. En el menú Inicio, seleccione Todos los programas, luego Microsoft Visual Studio, a continuación Visual Studio Tools, y luego Visual Studio 2010 Símbolo del sistema.

  2. En la ventana del símbolo del sistema, ejecuta el siguiente comando si estás usando C#:

    wsdl /language:CS /n:"ReportService2010" http://<Server Name>/reportserver/reportservice2010.asmx?wsdl  
    

    Si usa Visual Basic, ejecute el siguiente comando:

    wsdl /language:VB /n:"ReportService2010" http://<Server Name>/reportserver/reportservice2010.asmx?wsdl  
    

    Este comando genera un archivo .cs o .vb. Agregará este archivo a la aplicación.

Para crear una aplicación de consola

  1. En el menú Archivo , seleccione Nuevoy, a continuación, haga clic en Proyecto para abrir el cuadro de diálogo Nuevo proyecto .

  2. En el panel izquierdo, en Plantillas instaladas, haga clic en Visual Basic o en el nodo Visual C# y seleccione una categoría de tipos de proyecto en la lista expandida.

  3. Elija el tipo de proyecto Aplicación de consola .

  4. En el cuadro Nombre , escriba un nombre para el proyecto. Escriba el nombre SampleRDLSchema.

  5. En el cuadro Ubicación , escriba la ruta de acceso donde desea guardar el proyecto o haga clic en Examinar para ir a la carpeta.

  6. Haz clic en Aceptar. Aparece una vista colapsada de tu proyecto en el Explorador de soluciones.

  7. En el menú del proyecto , haga clic en Agregar elemento existente.

  8. Vaya a la ubicación del archivo .cs o .vb que generó, seleccione el archivo y, a continuación, haga clic en Agregar.

    También deberá agregar una referencia al Services espacio de nombres para que la referencia web funcione.

  9. En el menú Proyecto, haga clic en Agregar referencia.

    En el cuadro de diálogo Agregar referencia , en la pestaña .NET , seleccione System.Web.Services y haga clic en Aceptar.

    Para obtener más información sobre cómo conectarse al servicio web del servidor de informes, vea Compilar aplicaciones mediante el servicio web y .NET Framework.

  10. En el Explorador de soluciones, expanda el nodo del proyecto. Verá que un archivo de código con el nombre predeterminado Program.cs (Module1.vb para Visual Basic) se ha agregado a su proyecto.

  11. Abra el archivo Program.cs (Module1.vb para Visual Basic) y reemplace el código por lo siguiente:

    El código siguiente proporciona los códigos auxiliares del método que usaremos para implementar la funcionalidad Load, Update y Save.

    using System;  
    using System.Collections.Generic;  
    using System.IO;  
    using System.Text;  
    using System.Xml;  
    using System.Xml.Serialization;  
    using ReportService2010;  
    
    namespace SampleRDLSchema  
    {  
        class ReportUpdater  
        {  
            ReportingService2010 _reportService;  
    
            static void Main(string[] args)  
            {  
                ReportUpdater reportUpdater = new ReportUpdater();  
                reportUpdater.UpdateReport();  
            }  
    
            private void UpdateReport()  
            {  
                try  
                {  
                    // Set up the Report Service connection  
                    _reportService = new ReportingService2010();  
                    _reportService.Credentials =  
                        System.Net.CredentialCache.DefaultCredentials;  
                    _reportService.Url =  
                       "http://<Server Name>/reportserver/" +  
                                       "reportservice2010.asmx";  
    
                    // Call the methods to update a report definition  
                    LoadReportDefinition();  
                    UpdateReportDefinition();  
                    PublishReportDefinition();  
                }  
                catch (Exception ex)  
                {  
                    System.Console.WriteLine(ex.Message);  
                }  
            }  
    
            private void LoadReportDefinition()  
            {  
                //Lesson 3: Load a report definition from the report   
                //          catalog  
            }  
    
            private void UpdateReportDefinition()  
            {  
                //Lesson 4: Update the report definition using the    
                //          classes generated from the RDL Schema  
            }  
    
            private void PublishReportDefinition()  
            {  
                //Lesson 5: Publish the updated report definition back   
                //          to the report catalog  
            }  
        }  
    }  
    
    Imports System  
    Imports System.Collections.Generic  
    Imports System.IO  
    Imports System.Text  
    Imports System.Xml  
    Imports System.Xml.Serialization  
    Imports ReportService2010  
    
    Namespace SampleRDLSchema  
    
        Module ReportUpdater  
    
            Private m_reportService As ReportingService2010  
    
            Public Sub Main(ByVal args As String())  
    
                Try  
                    'Set up the Report Service connection  
                    m_reportService = New ReportingService2010  
                    m_reportService.Credentials = _  
                        System.Net.CredentialCache.DefaultCredentials  
                    m_reportService.Url = _  
                        "http:// <Server Name>/reportserver/" & _  
                               "reportservice2010.asmx"  
    
                    'Call the methods to update a report definition  
                    LoadReportDefinition()  
                    UpdateReportDefinition()  
                    PublishReportDefinition()  
                Catch ex As Exception  
                    System.Console.WriteLine(ex.Message)  
                End Try  
    
            End Sub  
    
            Private Sub LoadReportDefinition()  
                'Lesson 3: Load a report definition from the report   
                '          catalog  
            End Sub  
    
            Private Sub UpdateReportDefinition()  
                'Lesson 4: Update the report definition using the   
                '          classes generated from the RDL Schema  
            End Sub  
    
            Private Sub PublishReportDefinition()  
                'Lesson 5: Publish the updated report definition back   
                '          to the report catalog  
            End Sub  
    
        End Module  
    
    End Namespace   
    

Lección siguiente

En la siguiente lección, usará la Herramienta de definición de esquemas XML (Xsd.exe) para generar clases a partir del esquema RDL e incluirlas en el proyecto. Consulte Lección 2: Generar clases a partir del esquema RDL mediante la herramienta xsd.

Véase también

Actualización de informes mediante clases generadas a partir del esquema RDL (tutorial de SSRS)
Lenguaje de definición de informes (SSRS)