Share via


Lesson 1: Create the RDL Schema Visual Studio Project

For this tutorial, you will create a simple console application. This tutorial assumes you are developing in Microsoft Visual Studio 2005.

Note

When accessing the Report Server Web service running on SQL Server Express with Advanced Services, you must append "$SQLExpress" to the "ReportServer" path. For example:

http://myserver/reportserver$sqlexpress/reportservice2005.asmx"

To create a console application

  1. On the File menu, point to New, and then click Project to open the New Project dialog box.

  2. Expand either the Visual Basic Projects or the Visual C# Projects folder.

  3. Click the Console Application icon.

  4. In the Name box, enter a name for your project. Type the name SampleRDLSchema.

  5. In the Location box, type the path where you want to save your project, or click Browse to navigate to the folder.

  6. Click OK. A collapsed view of your project appears in Solution Explorer.

  7. Next, you will need to add a Web reference to the ReportService2005 endpoint. From the Project menu click Add Web Reference, and either type the URL path to your report server or navigate to it with the options in the browse window.

  8. Select the ReportService2005 endpoint, type ReportService2005 as the Web Reference Name, and then click the Add Reference button.

    For more information about how to connect to the Report Server Web service, see Tutorial: Accessing the Report Server Web Service Using Visual Basic or Visual C#.

  9. In Solution Explorer, expand the project node. You will see a code file with the default name of Program.cs (Module1.vb for Visual Basic) has been added to your project.

  10. Open the Program.cs (Module1.vb for Visual Basic) file and replace the code with the following:

    The following code provides the method stubs we will use to implement the Load, Update and Save functionality.

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

Next Lesson

In the next lesson, you will use the XML Schema Definition Tool (Xsd.exe) to generate classes from the RDL schema and include them in your project. See Lesson 2: Generate Classes from the RDL Schema using the xsd Tool.