December 8, 2008 at 2:52 pm
Hi Everybody,
I have an issue with the report publishing on to the report server using the ssrs 2005 webservices provided.
I use super user credentials for passing to report server to retrieve and delete the reports. ( the user has all the permission on the report server).
GenerateRdl(m_ReportName, e.StartDate, e.EndDate, (xyz.Libraries.Common.Carrier)Session["Company"]).Name.ToString().Trim() , headerNames);
CreateDataSource();
PublishReport(string reportName);
CODE IN THE PUBLISH REPORT:
private void PublishReport(string reportName)
{
try
{
// Create a stream reader and open file
// Could also create a stream without generating an RDL file
//StreamReader reader;
FileStream stream = File.OpenRead(Server.MapPath(filePath) + reportName + ".rdl");
// read the file into the definition
definition = new byte[stream.Length + 1];
stream.Read(definition, 0, (int)(stream.Length));
// close the stream
stream.Close();
}
catch (IOException ex)
{
throw new Exception("CopyOfAdhocReporting.cs::PublishReport(string reportName)", ex);
}
// Try creating the report using values filled
try
{
//bool inheritParent = false;
string myPropertyValue = "Table/View Name: " + viewRequired + " from " + connectionString + " Connection.";
myPropertyValue += " Columns Selected: " + orderList + ".";
myPropertyValue += " Note: This report uses " + dsName + " shared data source.";
// Set the description of the report to list the server name, table
// and fields used
Property newProp = new Property();
newProp.Name = "Description";
newProp.Value = myPropertyValue;
Property[] props = new Property[1];
props[0] = newProp;
RS.Credentials = new NetworkCredential(reportViewerUser, reportViewerPassword, reportViewerDomain);
// if the report exists in the folder delete and create new report
CatalogItem[] items = null;
SearchCondition condition = new SearchCondition();
condition.Condition = ConditionEnum.Equals;
condition.ConditionSpecified = true;
condition.Name = "Name";
condition.Value = m_ReportTitle;
SearchCondition[] conditions = new SearchCondition[1];
conditions[0] = condition;
try
{
items = RS.FindItems(parentPath, BooleanOperatorEnum.And, conditions);
if (items.Length != 0)
{
foreach (CatalogItem ci in items)
{
if (ci.Name == m_ReportTitle)
{
RS.DeleteItem(ci.Path);
warnings = RS.CreateReport(m_ReportTitle, parentPath, true, definition, props);
break;
}
else
{
warnings = RS.CreateReport(m_ReportTitle, parentPath, true, definition, props);
break;
}
}
}
else
{
warnings = RS.CreateReport(m_ReportTitle, parentPath, true, definition, props);
}
}
catch (SoapException e)
{
throw new Exception("CopyOfAdhocReporting.cs::SoapException - Deltete And Or Create Reports", e.InnerException);
}
FileInfo rdlFile = new FileInfo(Server.MapPath(filePath) + "\\" + reportName + ".rdl");
if (rdlFile.Exists)
{
File.Delete(Server.MapPath(filePath) + "\\" + reportName + ".rdl");
}
else
{
throw new FileNotFoundException();
}
}
This works well when i am in the intranet or in the LAN. But when i try generating report from my home which is out of LAN makes the report wrong. It comes correctly for the first time, but if i can the report parametres and generate it gives me the earlier report. It is not overwriting the existing report.
So i changed the logic to delete report if it exists using the search variables. But even i donno it works fine in the LAN but wrong out of LAN.
The user credentials used for the report server is the super user with all the permission to create and manage reports(has delete permissions even).
Any body with the same problem, please let me know.
Any help would be greatly appreciated.
Thanks,
Suman
January 17, 2009 at 4:54 am
Hi Suman,
Thanks for your posting, even though I can't solve your problem. I had the same requirement to upload "user generated" RDL files to our SSRS server. I used the FileStream snippet from you...thanks heaps.
Rgds
Uday
January 17, 2009 at 11:57 am
It is all working now for me. same code can be used. How r u creating the RDL file ?? And then create and publishing the rdl and datasource onto the report server.
Please let me know if u need any info.
Thanks,
Suman
May 15, 2009 at 10:44 am
Hi Suman,
Also wanted to say thanks heaps for your code snippet. I am just getting ready to program against the SSRS web service. I was wondering if you have coded a deployment for Report Builder through web services. We're using Forms Authentication and cannot use BIDS to deploy. The XML of the SMDL and DSV files needs to be combined in order to deploy through Report Manager and while I can hack this together, I'd rather have an interface for our users to deploy Ad-Hoc models. I am finding the documentation on SSRS web service programming a bit thin, even on the MSDN site. Also....have you found a good source of documentation and code snippets on this?
Linda
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply