Web サービスの Url プロパティの設定

Microsoft .NET Framework アプリケーションでは、アプリケーションのダイレクト先であるレポート サーバー Web サービスの基本 URL をいつでも変更できます。そのためには、サービス オブジェクトの Url プロパティを設定します。次に例を示します。

Dim rs As New ReportingService2005()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.Url = "http://myserver/reportserver/ReportingService2005.asmx"
ReportingService service = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://myserver/reportserver/ReportingService2005.asmx";

次の例では、1 つのレポート サーバーからレポート定義を取得し、その定義を使用して同じレポートを異なるレポート サーバーに作成します。

Imports System
Imports System.Web.Services.Protocols

Class Sample
   Public Shared Sub Main()
      Dim rs As New ReportingService2005()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials
      ' Set the base Web service URL of the source server
      rs.Url = "http://mySourceServer/reportserver/ReportingService2005.asmx"

      Dim reportName As String = "/SampleReports/Company Sales"
      Dim reportDefinition As Byte() = Nothing

      Try
         ' Get the report definition of a report on a source server
         reportDefinition = rs.GetReportDefinition(reportName)
         ' Set the base Web service URL of the destination server
         rs.Url = "http://myDestinationServer/reportserver/ReportingService2005.asmx"
         ' Create a copy of the report on the destination server
         rs.CreateReport("Company Sales Copy", "/", False, reportDefinition, Nothing)      
      Catch e As SoapException
         Console.WriteLine(e.Detail.InnerXml.ToString())
      End Try
   End Sub 'Main
End Class 'Sample
using System;
using System.Web.Services.Protocols;

class Sample
{
   public static void Main()
   {
      ReportingService2005 rs = new ReportingService2005();
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
      // Set the base Web service URL of the source server
      rs.Url = "http://mySourceServer/reportserver/reportservice.asmx";

      string reportName = "/SampleReports/Company Sales";
      byte[] reportDefinition = null;

      try
      {
         reportDefinition = rs.GetReportDefinition(reportName);
         // Set the base Web service URL of the destination server
         rs.Url = "http://myDestinationServer/reportserver/ReportingService2005.asmx";
         // Create a copy of the report on the destination server
         rs.CreateReport("Company Sales Copy", "/", false, reportDefinition, null);
      }

      catch (SoapException e)
      {
         Console.WriteLine(e.Detail.InnerXml.ToString()); 
      }
   }
}

Web サービスの最初のプロキシの作成の詳細については、「Web サービス プロキシの作成」を参照してください。

参照

関連項目

CreateReport
GetReportDefinition

その他の技術情報

Web サービスと .NET Framework を使用したアプリケーションの構築
レポート サーバー Web サービス

ヘルプおよび情報

SQL Server 2005 の参考資料の入手