次の方法で共有


レッスン 1 : RDL スキーマ Visual Studio プロジェクトの作成

このチュートリアルでは、簡単なコンソール アプリケーションを作成します。このチュートリアルでは、MicrosoftVisual Studio 2005 で開発することを前提としています。

注意注意

SQL Server Express with Advanced Services で実行されているレポート サーバー Web サービスにアクセスする場合は、"$SQLExpress" を "ReportServer" パスに追加する必要があります。次に例を示します。

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

コンソール アプリケーションを作成するには

  1. [ファイル] メニューの [新規作成] をポイントし、[プロジェクト] をクリックして、[新しいプロジェクト] ダイアログ ボックスを開きます。

  2. [Visual Basic プロジェクト] フォルダまたは [Visual C# プロジェクト] フォルダを展開します。

  3. [コンソール アプリケーション] アイコンをクリックします。

  4. [プロジェクト名] ボックスにプロジェクトの名前を入力します。「SampleRDLSchema」と入力します。

  5. [場所] ボックスにプロジェクトを保存するパスを入力するか、[参照] をクリックしてフォルダに移動します。

  6. [OK] をクリックします。ソリューション エクスプローラに、プロジェクトが折りたたまれた状態で表示されます。

  7. 次に、ReportService2005 エンドポイントに Web 参照を追加します。[プロジェクト] メニューの [Web 参照の追加] をクリックし、レポート サーバーへの URL パスを入力するか、参照ウィンドウを使って指定します。

  8. ReportService2005 エンドポイントを選択して、[Web 参照名] に「ReportService2005」と入力し、[参照の追加] をクリックします。

    レポート サーバー Web サービスへの接続方法の詳細については、「チュートリアル : Visual Basic または Visual C# を使用したレポート サーバー Web サービスへのアクセス」を参照してください。

  9. ソリューション エクスプローラで、このプロジェクトのノードを展開します。プロジェクトには、Program.cs (Visual Basic の場合は Module1.vb) という既定の名前のコード ファイルが追加されていることがわかります。

  10. Program.cs (Visual Basic の場合は Module1.vb) ファイルを開き、次のコードに置き換えます。

    次のコードは、読み込み、変更、保存の機能を実装するときに使用するメソッドの一部です。

    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 
    

次のレッスン

次のレッスンでは、XML スキーマ定義ツール (Xsd.exe) を使用して RDL スキーマからクラスを生成し、プロジェクトに組み込みます。「レッスン 2 : xsd ツールを使用して RDL スキーマからクラスを作成」を参照してください。