Share via


Festlegen der URL-Eigenschaft des Webdiensts

Sie können die Basis-URL des Berichtsserver-Webdiensts, auf den Ihre Anwendung derzeit gerichtet ist, jederzeit in Ihren Microsoft.NET Framework-Anwendungen ändern. Hierzu legen Sie einfach die URL-Eigenschaft des Dienstobjekts fest. Beispiel:

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

Im folgenden Beispiel wird eine Berichtsdefinition von einem Berichtsserver abgerufen. Mit dieser Definition wird ein identischer Bericht auf einem anderen Berichtsserver erstellt:

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://<Server Name>/reportserver/ReportService2005.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://<Server Name>/reportserver/ReportService2005.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://<Server Name>/reportserver/reportservice2005.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://<Server Name>/reportserver/ReportService2005.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()); 
      }
   }
}

Weitere Informationen zum Erstellen des ersten Webdienst-Proxy finden Sie unter Erstellen des Webdienstproxys.