Share via


ReportingService2005.CreateSubscription Method

Creates a subscription for a specified report in the report server database.

Namespace: Microsoft.WSSUX.ReportingServicesWebService.RSManagementService2005
Assembly: ReportService2005 (in reportingservice2005.dll)

Syntax

'Declaration
<SoapHeaderAttribute("BatchHeaderValue")> _
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CreateSubscription", RequestNamespace:="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace:="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
<SoapHeaderAttribute("ServerInfoHeaderValue", Direction:=SoapHeaderDirection.Out)> _
Public Function CreateSubscription ( _
    Report As String, _
    ExtensionSettings As ExtensionSettings, _
    Description As String, _
    EventType As String, _
    MatchData As String, _
    Parameters As ParameterValue() _
) As String
[SoapHeaderAttribute("BatchHeaderValue")] 
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CreateSubscription", RequestNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)] 
[SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out)] 
public string CreateSubscription (
    string Report,
    ExtensionSettings ExtensionSettings,
    string Description,
    string EventType,
    string MatchData,
    ParameterValue[] Parameters
)
[SoapHeaderAttribute(L"BatchHeaderValue")] 
[SoapDocumentMethodAttribute(L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CreateSubscription", RequestNamespace=L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace=L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse::Literal, ParameterStyle=SoapParameterStyle::Wrapped)] 
[SoapHeaderAttribute(L"ServerInfoHeaderValue", Direction=SoapHeaderDirection::Out)] 
public:
String^ CreateSubscription (
    String^ Report, 
    ExtensionSettings^ ExtensionSettings, 
    String^ Description, 
    String^ EventType, 
    String^ MatchData, 
    array<ParameterValue^>^ Parameters
)
/** @attribute SoapHeaderAttribute("BatchHeaderValue") */ 
/** @attribute SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CreateSubscription", RequestNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped) */ 
/** @attribute SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out) */ 
public String CreateSubscription (
    String Report, 
    ExtensionSettings ExtensionSettings, 
    String Description, 
    String EventType, 
    String MatchData, 
    ParameterValue[] Parameters
)
SoapHeaderAttribute("BatchHeaderValue") 
SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CreateSubscription", RequestNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", ResponseNamespace="https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped) 
SoapHeaderAttribute("ServerInfoHeaderValue", Direction=SoapHeaderDirection.Out) 
public function CreateSubscription (
    Report : String, 
    ExtensionSettings : ExtensionSettings, 
    Description : String, 
    EventType : String, 
    MatchData : String, 
    Parameters : ParameterValue[]
) : String

Parameters

  • Report
    The full path name of the report for which to create a subscription.
  • ExtensionSettings
    An ExtensionSettings object that contains a list of settings that are specific to the delivery extension.
  • Description
    A meaningful description that is displayed to users.
  • EventType
    The type of event that triggers the subscription. The valid values are TimedSubscription or SnapshotUpdated.
  • MatchData
    The data that is associated with the specified EventType parameter. This parameter is used by an event to match the subscription with an event that has fired.
  • Parameters
    An array of ParameterValue objects that contains a list of parameters for the report.

Return Value

A subscription ID, which uniquely identifies the subscription in the report server database.

Remarks

You can use the GetExtensionSettings method to retrieve a list of required settings for a delivery extension. You must pass values for these required settings in the ExtensionSettings parameter. For information about e-mail delivery settings, see Reporting Services Delivery Extension Settings.

The value of the EventType parameter must correspond to an event that is configured for the report server. The two events that are used to create subscriptions are TimedSubscription and SnapshotUpdated. Use the ListEvents method to return a list of all events configured for the report server.

The value of the MatchData parameter depends on the event type. If the event is a TimedSubscription event, a ScheduleDefinition object is required as the MatchData parameter. You must first serialize the ScheduleDefinition object as XML in order to pass it as a string value and create a subscription based on the schedule. The XML structure might look like the one in the following example:

<ScheduleDefinition>
   <WeeklyRecurrence>
      <StartDateTime>2004-06-24T09:00:00-08:00</StartDateTime>
      <WeeksInterval>1</WeeksInterval>
      <DaysOfWeek>
         <Monday>True</Monday>
         </DaysOfWeek>
   </WeeklyRecurrence>
</ScheduleDefinition>

The value of the StartDateTime element when passed as an XML string should correspond to the date format ISO 8601. This international date and time standard is the extended format CCYY-MM-DDThh:mm:ss+/-Z where "CC" represents the century, "YY" the year, "MM" the month and "DD" the day. The letter "T" is the date and time separator and "hh", "mm", "ss" represent hour, minute and second respectively. This representation may be immediately followed by a "Z" to indicate Coordinated Universal Time (UTC). To indicate the time zone, represented as the difference between the local time and Coordinated Universal Time, "Z" is preceded by a "+" or "-" sign, followed by the difference from UTC represented as hh:mm.

If the schedule definition for a TimedSubscription is a shared schedule, you must pass the schedule ID of the shared schedule as the MatchData parameter. The schedule ID is passed as a String, for example, "4608ac1b-fc75-4149-9e15-5a8b5781b843". The schedule ID can be obtained by calling the ListSchedules method.

You can use the XmlSerializer class to convert your object class to an XML string automatically. For more information about the XmlSerializer class, see "System.Xml.XmlSerializer Class" in the Microsoft .NET Framework documentation.

If the event is a SnapshotUpdated subscription, the value of MatchData should be null (or Nothing in Visual Basic).

Using this method sets the LastExecuted property of the report to none, the Status property of the subscription to new subscription, and the Active property of the subscription to true. The ModifiedBy and ModifiedDate properties of the report are also updated.

Example

To compile this code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see Compiling and Running Code Examples. The following code example uses CreateSubscription to add a new subscription to the report server database:

Imports System
Imports System.Web.Services.Protocols

Class Sample
   Public Shared Sub Main()
      Dim rs As New ReportingService2005()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials

      Dim report As String = "/SampleReports/Employee Sales Summary"
      Dim desc As String = "Send email to anyone@microsoft.com"
      Dim eventType As String = "TimedSubscription"
      Dim scheduleXml As String = "<ScheduleDefinition><StartDateTime>2003-02-24T09:00:00-08:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"

      Dim extensionParams(7) As ParameterValue

      extensionParams(0) = New ParameterValue()
      extensionParams(0).Name = "TO"
      extensionParams(0).Value = "dank@adventure-works.com"

      extensionParams(1) = New ParameterValue()
      extensionParams(1).Name = "ReplyTo"
      extensionParams(1).Value = "reporting@adventure-works.com"

      extensionParams(2) = New ParameterValue()
      extensionParams(2).Name = "IncludeReport"
      extensionParams(2).Value = "True"

      extensionParams(3) = New ParameterValue()
      extensionParams(3).Name = "RenderFormat"
      extensionParams(3).Value = "MHTML"

      extensionParams(4) = New ParameterValue()
      extensionParams(4).Name = "Subject"
      extensionParams(4).Value = "@ReportName was executed at @ExecutionTime"

      extensionParams(5) = New ParameterValue()
      extensionParams(5).Name = "Comment"
      extensionParams(5).Value = "Here is your daily sales report for Michael."

      extensionParams(6) = New ParameterValue()
      extensionParams(6).Name = "IncludeLink"
      extensionParams(6).Value = "True"

      extensionParams(7) = New ParameterValue()
      extensionParams(7).Name = "Priority"
      extensionParams(7).Value = "NORMAL"

      Dim parameter As New ParameterValue()
      parameter.Name = "EmpID"
      parameter.Value = "38"

      Dim parameters(1) As ParameterValue
      parameters(0) = parameter

      Dim matchData As String = scheduleXml
      Dim extSettings As New ExtensionSettings()
      extSettings.ParameterValues = extensionParams
      extSettings.Extension = "Report Server Email"

      Try
         rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters)

      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;

      string report = "/SampleReports/Employee Sales Summary";
      string desc = "Send email to anyone@microsoft.com";
      string eventType = "TimedSubscription";
      string scheduleXml = @"<ScheduleDefinition><StartDateTime>2003-02-24T09:00:00-08:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>";

      ParameterValue[] extensionParams = new ParameterValue[8];

      extensionParams[0] = new ParameterValue();
      extensionParams[0].Name = "TO";
      extensionParams[0].Value = "dank@adventure-works.com";

      extensionParams[1] = new ParameterValue();
      extensionParams[1].Name = "ReplyTo";
      extensionParams[1].Value = "reporting@adventure-works.com";

      extensionParams[2] = new ParameterValue();
      extensionParams[2].Name = "IncludeReport";
      extensionParams[2].Value = "True";

      extensionParams[3] = new ParameterValue();
      extensionParams[3].Name = "RenderFormat";
      extensionParams[3].Value = "MHTML";

      extensionParams[4] = new ParameterValue();
      extensionParams[4].Name = "Subject";
      extensionParams[4].Value = "@ReportName was executed at @ExecutionTime";

      extensionParams[5] = new ParameterValue();
      extensionParams[5].Name = "Comment";
      extensionParams[5].Value = "Here is your daily sales report for Michael.";

      extensionParams[6] = new ParameterValue();
      extensionParams[6].Name = "IncludeLink";
      extensionParams[6].Value = "True";

      extensionParams[7] = new ParameterValue();
      extensionParams[7].Name = "Priority";
      extensionParams[7].Value = "NORMAL";

      ParameterValue parameter = new ParameterValue();
      parameter.Name = "EmpID";
      parameter.Value = "38";

      ParameterValue[] parameters = new ParameterValue[1];
      parameters[0] = parameter;

      string matchData = scheduleXml;
      ExtensionSettings extSettings = new ExtensionSettings();
      extSettings.ParameterValues = extensionParams;
      extSettings.Extension = "Report Server Email";

      try
      {
         rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters);
      }

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

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

See Also

Reference

ReportingService2005 Class
ReportingService2005 Members
Microsoft.WSSUX.ReportingServicesWebService.RSManagementService2005 Namespace