이 자습서에서는 간단한 콘솔 애플리케이션을 만듭니다. 이 자습서에서는 사용자가 Microsoft Visual Studio 2010에서 개발 중이라고 가정합니다.
비고
고급 서비스를 사용하여 SQL Server Express에서 실행되는 보고서 서버 웹 서비스에 액세스할 때 "reportServer" 경로에 "_SQLExpress"를 추가해야 합니다. 다음은 그 예입니다.
http://myserver/reportserver_sqlexpress/reportservice2010.asmx"
웹 서비스 프록시를 만들려면
시작 메뉴에서 모든 프로그램, Microsoft Visual Studio, Visual Studio 도구, Visual Studio 2010 명령 프롬프트를 차례로 선택합니다.
C#을 사용하는 경우 명령 프롬프트 창에서 다음 명령을 실행합니다.
wsdl /language:CS /n:"ReportService2010" http://<Server Name>/reportserver/reportservice2010.asmx?wsdlVisual Basic을 사용하는 경우 다음 명령을 실행합니다.
wsdl /language:VB /n:"ReportService2010" http://<Server Name>/reportserver/reportservice2010.asmx?wsdl이 명령은 .cs 또는 .vb 파일을 생성합니다. 이 파일을 애플리케이션에 추가합니다.
콘솔 애플리케이션을 만들려면
[파일] 메뉴에서 [새로 만들기]를 가리킨 다음 [프로젝트]를 클릭하여 [새 프로젝트] 대화 상자를 엽니다.
왼쪽 창의 설치된 템플릿 아래에서 Visual Basic 또는 Visual C# 노드를 클릭하고 확장된 목록에서 프로젝트 형식의 범주를 선택합니다.
콘솔 애플리케이션 프로젝트 유형을 선택합니다.
이름 상자에 프로젝트의 이름을 입력합니다. 이름을
SampleRDLSchema입력합니다.위치 상자에 프로젝트를 저장할 경로를 입력하거나 찾아보기를 클릭하여 폴더로 이동합니다.
OK를 클릭합니다. 프로젝트의 축소된 보기가 솔루션 탐색기에 표시됩니다.
프로젝트 메뉴에서 기존 항목 추가클릭합니다.
생성한 .cs 또는 .vb 파일의 위치로 이동한 다음 파일을 선택한 다음 추가를 클릭합니다.
웹 참조가 작동하려면 Services 네임스페이스에 대한 참조를 추가해야 합니다.
프로젝트 메뉴에서 참조 추가를 클릭합니다.
참조 추가 대화 상자의 .NET 탭에서 System.Web.Services를 선택한 다음 확인을 클릭합니다.
보고서 서버 웹 서비스에 연결하는 방법에 대한 자세한 내용은 웹 서비스 및 .NET Framework를 사용하여 애플리케이션 빌드를 참조하세요.
솔루션 탐색기에서 프로젝트 노드를 확장합니다. 기본 이름이 Program.cs 코드 파일(Visual Basic용 Module1.vb)이 프로젝트에 추가된 것을 볼 수 있습니다.
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 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
다음 단원:
다음 단원에서는 XML 스키마 정의 도구(Xsd.exe)를 사용하여 RDL 스키마에서 클래스를 생성하고 프로젝트에 포함합니다. 2단원: xsd 도구를 사용하여 RDL 스키마에서 클래스 생성을 참조하세요.