Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Reporting Services
Development
Developer's Guide
 Setting the Url Property of the Web...
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
SQL Server 2008 Books Online (November 2009)
Setting the Url Property of the Web Service

At any time in your Microsoft .NET Framework applications, you can modify the base URL of the Report Server Web service to which your application is currently directed. To do this, simply set the Url property of the service object. For example:

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

The following example retrieves a report definition from one report server and uses that definition to create an identical report on a different report server:

Visual Basic
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
C#
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()); 
      }
   }
}

For more information about creating the initial Web service proxy, see Creating the Web Service Proxy.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker