0

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
4

1 に答える 1

0

私は周りに仕事を見つけました。

この投稿で言うように、代わりに2005WSを使用して2010に変更しました

SSRSでユーザーのサブスクリプションを自動的に設定する

そしてそれはうまくいった。

これがコードです。

 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
于 2012-10-10T20:19:32.883 に答える