s-s-rS 订阅,BatchHead 参数
Posted
技术标签:
【中文标题】s-s-rS 订阅,BatchHead 参数【英文标题】:s-s-rS Subscriptions, BatchHead parameter 【发布时间】:2012-10-10 17:24:07 【问题描述】:我正在尝试使用 Web 服务创建订阅,该方法没有抛出任何异常,但也没有创建订阅。
搜索我在大多数论坛和帮助文件上看到的信息,CreateSubscription 方法不要求批处理头,但我的要求是,所以我认为这可能与我的安装有关。
这是我的代码。
Dim rs As New reportingReference.ReportingService2005SoapClient
rs.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultCredentials
'rs.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
rs.ClientCredentials.Windows.AllowedImpersonationLevel = New System.Security.Principal.TokenImpersonationLevel()
Dim batchID As String = String.Empty
Dim infoHeader As ServerInfoHeader = rs.CreateBatch(batchID)
Dim bh As BatchHeader = New BatchHeader()
bh.BatchID = batchID
bh.AnyAttr = infoHeader.AnyAttr
Dim report As String = "/reportParam1"
Dim desc As String = "Send email from code to Hisham@comsoft.com"
Dim eventType As String = "TimedSubscription"
Dim scheduleXml As String = "<ScheduleDefinition><StartDateTime>2012-03-22T09:30:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Thursday>True</Thursday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
'"<ScheduleDefinition><StartDateTime>2012-10-06T08:00:00-08:00</StartDateTime><WeeklyRecurrence>" & _
'"<WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>" ' "<ScheduleDefinition xmlns:xsd=\""http://www.w3.org/2001/XMLSchema\"" xmlns:xsi=\""http://www.w3.org/2001/XMLSchema-instance\""><StartDateTime xmlns=\""http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\"">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>"
Dim extensionParams(7) As ParameterValue
extensionParams(0) = New ParameterValue()
extensionParams(0).Name = "TO"
extensionParams(0).Value = "rocha@costarricense.cr"
extensionParams(1) = New ParameterValue()
extensionParams(1).Name = "IncludeReport"
extensionParams(1).Value = "True"
extensionParams(2) = New ParameterValue()
extensionParams(2).Name = "RenderFormat"
extensionParams(2).Value = "Mhtml"
extensionParams(3) = New ParameterValue()
extensionParams(3).Name = "Subject"
extensionParams(3).Value = "@ReportName was executed at @ExecutionTime"
extensionParams(4) = New ParameterValue()
extensionParams(4).Name = "Comment"
extensionParams(4).Value = "Here is your test report for testing purpose"
'extensionParams(5) = New ParameterValue()
'extensionParams(5).Name = "IncludeLink"
'extensionParams(5).Value = "True"
extensionParams(5) = New ParameterValue()
extensionParams(5).Name = "Priority"
extensionParams(5).Value = "NORMAL"
Dim parameters(0) As ParameterValue
parameters(0) = New ParameterValue()
parameters(0).Name = "ReportParameter1"
parameters(0).Value = "ReportParameter1"
'parameters(1) = New ParameterValue()
'parameters(1).Name = "UserName"
'parameters(1).Value = "admin"
'parameters(2) = New ParameterValue()
'parameters(2).Name = "SupplierId"
'parameters(2).Value = "0"
Dim matchData As String = scheduleXml
Dim extSettings As New ExtensionSettings()
extSettings.ParameterValues = extensionParams
extSettings.Extension = "Report Server Email"
Try
Dim _sub As String = ""
Dim SubID As ServerInfoHeader = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, _sub)
rs.FireEvent(bh, "TimedSubscription", _sub)
Catch ex As Exception
Console.WriteLine(ex)
End Try
【问题讨论】:
【参考方案1】:我找到了一个工作区。
而不是使用 2005 WS,我将其更改为 2010,如本文所述
Automatically set up user's subscription in s-s-rS
它奏效了。
这里是代码。
Private Sub Suscription2010()
Dim service As New ServiceReference1.ReportingService2010SoapClient()
service.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials
service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation
Dim userHeader As New ServiceReference1.TrustedUserHeader()
Dim desc As String = "Send to Document Library"
Dim eventType As String = "TimedSubscription"
Dim scheduleXml As String = "<ScheduleDefinition>" + _
" <StartDateTime>2010-11-30T08:00:00-08:00" + _
" </StartDateTime>" + _
" <WeeklyRecurrence>" + _
" <WeeksInterval>1</WeeksInterval>" + _
" <DaysOfWeek>" + _
" <Monday>True</Monday>" + _
" </DaysOfWeek>" + _
" </WeeklyRecurrence>" + _
"</ScheduleDefinition>"
Dim extensionParams(4) As ServiceReference1.ParameterValue
extensionParams(0) = New ServiceReference1.ParameterValue()
extensionParams(0).Name = "TO"
extensionParams(0).Value = "my alias"
extensionParams(1) = New ServiceReference1.ParameterValue()
extensionParams(1).Name = "IncludeReport"
extensionParams(1).Value = "FALSE"
extensionParams(2) = New ServiceReference1.ParameterValue()
extensionParams(2).Name = "IncludeLink"
extensionParams(2).Value = "TRUE"
extensionParams(3) = New ServiceReference1.ParameterValue()
extensionParams(3).Name = "Subject"
extensionParams(3).Value = "@ReportName was executed at @ExecutionTime"
Dim matchData As String = scheduleXml
Dim extSettings As New ServiceReference1.ExtensionSettings
extSettings.ParameterValues = extensionParams
extSettings.Extension = "Report Server Email"
Dim id As String
service.CreateSubscription(userHeader, "/reportname", extSettings, desc, eventType, matchData, Nothing, id)
End Sub
【讨论】:
以上是关于s-s-rS 订阅,BatchHead 参数的主要内容,如果未能解决你的问题,请参考以下文章