command line:
rs.exe -i MyScriptFile.rss -s "MyReportServer/ReportServer"
The input scriptfile (MyScriptFile) contains the lines below where the scheduleID is taken from Reporting Services from an existing 'once only' schedule. The schedule, - when triggered - should fire off a subscription and email recipients with a particular existing report.
Sub Main
Dim rs As New ReportingService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.FireEvent("TimedSubscription", "87206163-7665-4458-a86c-75b84cf18b2d")
End Sub
Unfortunately, it doesn't work and I almost always get the response:
Unhandled exception:
The request failed with HTTP status 404: Not Found.
If I comment out the line rs.FireEvent( . . . from the script then the command line runs successfully. I can only conclude that there appears to be something wrong with this particular line.
Any ideas anyone?
Kev
Rs.exe takes care of creating the proxy to SSRS and doing authentication, so the first two lines of code (Dim RS & rs.Credentials) aren't actually necessary. The rest of your code looks fine, though.
You're saying that it sometimes does work?
Here are a few things to try:
- Can you check your Subscription ID to make sure it actually exists?
- Does this code work against a Subscription ID directly (in code) from a different (known good) subscription? (For example, see if this sample works: http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.fireevent.aspx)
- FireEvent is the only method you're actually firing against the SOAP API...why don't you include another before you call FireEvent (something simple like ListChildren()) to make sure that the web service can do *any* work on your behalf.
- I've never seen someone specify the server name in their command-line w/o appending http:// first. This mean it won't work, I've just never seen it. Can you try something like this: rs.exe -i myFile.rss -s http://localhost/reportserver -u myDomain\myAccount -p myPassword ? Do this after you remove the first two lines of your code.
Let us know...good luck!
|||Russell, Thanks tremendously for the reply! I spent two whole days on this (without success) trying every variation I could think of.Firstly, no the code in the original post has never worked; I've not been able to trigger anything. The Subscription ID definitely exists however: I highlighted it and copied it from within the Reporting Services address bar (in the Scheduling page) directly making sure I had it perfect. I did wonder whether it 'was' the intended ScheduleID but the address bar in the browser reads:
http://MyServer/Reports/Pages/Schedule.aspx?ScheduleID=87206163-7665-4458-a86c-75b84cf18b2d
. . . so I am assuming that I really 'do' indeed have the correct ScheduleID it's looking for (87206163-7665-4458-a86c-75b84cf18b2d)? Or is it? I've tried this with double quotes, without quotes, with single quotes all with no luck.
Secondly, the code below works perfectly indicating that the SOAP API will indeed do something for me:
rs.exe -i ListFormatExtensions.rss -s "MyServer/ReportServer"
with the following code in the ListFormatExtensions.rss file:
Sub Main
For Each Ext As Extension In rs.ListExtensions(ExtensionTypeEnum.Render)
Console.WriteLine(Ext.Name)
Next
End Sub
Strangely, ListChildren (as you suggested) didn't work at all? It failed with error BC30451: Name 'ListChildren' is not declared. I would assume that this is something perhaps due to the fact that I am using Reporting Services 2000 and not 2005? The actual failed code I used in the rss file was:
Sub Main
Dim rs As New ReportingService()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
rs.ListChildren()
rs.FireEvent("TimedSubscription", "87206163-7665-4458-a86c-75b84cf18b2d")
End Sub
The server name also works either way I specify it with the ListFormatExtensions test. So both these code snippets work happily and there's no issue with username and password:
rs.exe -i ListFormatExtensions.rss -s "MyServer/ReportServer"
rs.exe -i ListFormatExtensions.rss -s http://MyServer/ReportServer
I tried the option you suggested (without the first two lines of code) which it didn't like:
Sub Main
FireEvent("TimedSubscription", "87206163-7665-4458-a86c-75b84cf18b2d")
End Sub
error BC30451: Name 'FireEvent' is not declared
. . . so I promptly put the first two lines back in.
I am still trying to figure out what you mean by - Does this code work against a Subscription ID directly (in code) from a different (known good) subscription? (For example, see if this sample works: http://msdn2.microsoft.com/en-us/library/microsoft.wssux.reportingserviceswebservice.rsmanagementservice2005.reportingservice2005.fireevent.aspx)
The web address you gave simply takes me straight to the MSDN definition for FireEvent in Reporting Services 2005.
Kev
|||
Hey Kev --
Even though you can remove "Dim RS", etc. you still use "rs.Whatever" in your code
This worked for me:
1. Created a new subscription off the Adventure Works - Company Sales report: Used the fileshare delivery extension because I don't have an SMTP server handy
2. Put it on a schedule that would not fire until 3 days from now
3. Executed select * from reportserver..subscriptions to get the Subscription ID
4. Threw code below in an RSS file:
Sub Main()
Try
rs.FireEvent("TimedSubscription", "E34849EE-63EE-4BF6-957F-55A9B1132DDB")
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Sub
5. In Report Manager, made sure that my user had "Generate Events" permissions (a system permission)
6. Executed the code with rs.exe -i c:\tryme.rss -s http://servername/reportserver
7. Checked my fileshare, found the report sitting there.
Yes, make sure that you are using the subscription ID, as Russell is, and not the schedule ID that you said you were using.
-Daniel
|||Guys, thanks for your input!! The problem is now sorted.
Unfortunately, I never gave a thought to the fact that I was running the rs.exe command on my own desktop and not the server on which Reporting Services is actually installed ! Dumb hey! When I put the file TriggerReport.rss on the report server and then ran the command to execute on the report server itself (using the psexec command):
psexec \\myserver rs.exe -i C:\TriggerReport.rss -s "http://myserver/ReportServer"
. . . it triggered the report immediately. The report promptly arrived in my email. I guess the lesson here is to stand back often and ask yourself if you're doing anything obviously stupid before blaming the code.
Kev
|||What Imports do you need for your .NET app if using SSRS 2005? Just thought I'd ask since you guys are the only place I've found really good info on this subject.
没有评论:
发表评论