보고서에 보고서 서버 웹 서비스에 대한 참조를 프로젝트에 추가한 후 다음 단계는 웹 서비스의 프록시 클래스 인스턴스를 만드는 것입니다. 그런 다음 프록시 클래스에서 메서드를 호출하여 웹 서비스의 메서드에 액세스할 수 있습니다. 애플리케이션이 이러한 메서드를 호출하면 Visual Studio에서 생성된 프록시 클래스 코드가 애플리케이션과 웹 서비스 간의 통신을 처리합니다.
먼저 웹 서비스의 프록시 클래스 ReportingService2010인스턴스를 만듭니다. 다음으로 프록시 클래스를 사용하여 웹 서비스의 GetProperties 메서드를 호출합니다. 호출을 사용하여 샘플 보고서 중 하나인 Company Sales의 이름과 설명을 검색합니다.
비고
고급 서비스를 사용하여 SQL Server Express에서 실행되는 웹 서비스에 액세스할 때 "reportServer" 경로에 "$SQLExpress"를 추가해야 합니다. 다음은 그 예입니다.
http://<Server Name>/reportserver$sqlexpress/reportservice2010.asmx"
웹 서비스에 액세스하려면
먼저 코드 파일에 (Visual Basic에서) 지시문을 추가하여 Program.cs 파일(Visual Basic의 Module1.vb)에 네임스페이스를 추가
usingImports해야 합니다. 이 지시문을 사용하는 경우 네임스페이스의 형식을 정규화할 필요가 없습니다.이렇게 하려면 코드 파일의 시작 부분에 다음 코드를 추가합니다.
Imports System Imports GetPropertiesSample.ReportService2010using System; using GetPropertiesSample.ReportService2010;코드 파일에 네임스페이스 지시문을 입력한 후 콘솔 애플리케이션의 Main 메서드에 다음 코드를 입력합니다. 웹 서비스 인스턴스의 Url 속성을 설정할 때 서버 이름을 변경해야 합니다.
Sub Main() Dim rs As New ReportingService2010 rs.Credentials = System.Net.CredentialCache.DefaultCredentials rs.Url = "http://<Server Name>/reportserver/reportservice2010.asmx" Dim name As New [Property] name.Name = "Name" Dim description As New [Property] description.Name = "Description" Dim properties(1) As [Property] properties(0) = name properties(1) = description Try Dim returnProperties As [Property]() = rs.GetProperties( _ "/AdventureWorks 2012 Sample Reports/Company Sales 2012", properties) Dim p As [Property] For Each p In returnProperties Console.WriteLine((p.Name + ": " + p.Value)) Next p Catch e As Exception Console.WriteLine(e.Message) End Try End Substatic void Main(string[] args) { ReportingService2010 rs = new ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = "http://<Server Name>/reportserver/reportservice2010.asmx"; Property name = new Property(); name.Name = "Name"; Property description = new Property(); description.Name = "Description"; Property[] properties = new Property[2]; properties[0] = name; properties[1] = description; try { Property[] returnProperties = rs.GetProperties( "/AdventureWorks 2012 Sample Reports/Company Sales 2012",properties); foreach (Property p in returnProperties) { Console.WriteLine(p.Name + ": " + p.Value); } } catch (Exception e) { Console.WriteLine(e.Message); } }솔루션을 저장합니다.
연습 샘플 코드는 웹 서비스의 GetProperties 메서드를 이용하여 샘플 보고서 Company Sales 2012의 속성을 가져옵니다. 이 메서드는 GetProperties 두 개의 인수를 사용합니다. 속성 정보를 검색하려는 보고서의 이름과 값을 검색하려는 속성의 이름이 들어 있는 Property[] 개체의 배열입니다. 또한 이 메서드는 속성 인수에 지정된 속성의 이름과 값을 포함하는 Property[] 개체의 배열을 반환합니다.
비고
속성 인수에 빈 Property[] 배열을 제공하면 사용 가능한 모든 속성이 반환됩니다.
이전 샘플에서 코드는 이 메서드를 GetProperties 사용하여 샘플 보고서인 Company Sales 2012의 이름과 설명을 반환합니다. 그런 다음 코드는 루프를 foreach 사용하여 속성 및 값을 콘솔에 씁니다.
보고서 서버 웹 서비스에 대한 프록시 클래스를 만들고 사용하는 방법에 대한 자세한 내용은 웹 서비스 프록시 만들기를 참조하세요.
또한 참조하십시오
4단원: 애플리케이션 실행(VB-VC#)
Visual Basic 또는 Visual C#을 사용하여 보고서 서버 웹 서비스에 액세스(SSRS 자습서)