Monday, March 19, 2012

Getting report chart images from reports with parameters...not wor

I've been rendering chart images successfully for a report using the
ReportingService web services for a few weeks now. Today I had to add a
parameter to the report and now after I call my render method and loop
through the returned streamId's to get the images, I get the exception:
"rsStreamNotFound The stream cannot be found. The stream identifier that is
provided to an operation cannot be located in the report server database."
Why would this be happening?! I'm looping through the very streamId's that
the render method just returned to me!
Thanks in advance, Brian ParkerI figured out how to get around this. If the report you render has
parameters, you just take the parameterUsed collection and pass it into the
parameters argument of the renderStream method! The documentation for the
render method states "This parameter returns a value only if the report being
rendered is a report history snapshot.". Well this is not true..the
documentation should be changed and the renderStream method documentation
should state that you can pass the parametersUsed collection into the
parmeters argument.
Here's a snippet that works for me...
<snip>
// Render the report to HTML4.0
result = rs.Render(ConfigurationSettings.AppSettings["ReportSrc"],
"HTML4.0", null,
"<DeviceInfo><StreamRoot>" +
ConfigurationSettings.AppSettings["ImageDir"] +
ConfigurationSettings.AppSettings["ImagePrefix"] +
"</StreamRoot></DeviceInfo>",
parameters, null, null, out optionalString, out optionalString,
out optionalParams,
out optionalWarnings, out streamIDs);
// For each image stream returned by the call to render,
// render the stream and save it to the specified folder
foreach (string streamID in streamIDs)
{
image =rs.RenderStream(ConfigurationSettings.AppSettings["ReportSrc"], "HTML4.0",
streamID,
null ,null, optionalParams, out optionalString, out
optionalString);
// do something with the returned image...
}
</snip>
"Brian Parker" wrote:
> I've been rendering chart images successfully for a report using the
> ReportingService web services for a few weeks now. Today I had to add a
> parameter to the report and now after I call my render method and loop
> through the returned streamId's to get the images, I get the exception:
> "rsStreamNotFound The stream cannot be found. The stream identifier that is
> provided to an operation cannot be located in the report server database."
> Why would this be happening?! I'm looping through the very streamId's that
> the render method just returned to me!
> Thanks in advance, Brian Parker
>|||After reading my second post, I don't know if I was clear enough about what
was wrong with the documentation.
1) On ReportServices.render method, the argument called 'parameterUsed' does
not only return a value if the rendered report is a snapshot, as the
documentation states.
2) On the ReportServices.renderStream method, the argument called Parameters
is manditory if you want to pull in an image from a report that has
parameters. When you leave this argument null and try to use the Stream
array returned from the render method, you will get an exception. If you use
the streamid in conjunction with passing the parameters argument in, you'll
be good to go.
Perhaps this is a bug that will be fixed and this solution will no longer be
necessary. Could someone at microsoft please verify this?

No comments:

Post a Comment