File does not upload to Report Server
I am trying to upload a report from the file system to the report server, but for some reason the report doesn't appear when I upload it
Here is the section of code:
WebClient reptserv = new WebClient();
File.WriteAllLines(@"C:\HereGoesNothing.rdl", lines);
Uri address = new Uri("http://localhost/reportserver")开发者_JAVA百科;
reptserv.UploadFileAsync(address, @"C:\HereGoesNothing.rdl");
The report runs in report builder just fine, so I know that's not the issue, but after that I'm stumped.
Look at the below so question's answer, this is a better method of achieving what you want to do... Upload a report file to Report manager via .net application?
Basically you add a service reference to the report server and then upload it via the proxy class, also look at: http://msdn.microsoft.com/en-us/library/aa237438%28SQL.80%29.aspx
public static void createReport()
{
ReportingService rs = new ReportingService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
Byte[] definition = null;
Warning[] warnings = null;
string name = "HereGoesNothing";
try
{
FileStream stream = File.OpenRead(@"C:\HereGoesNothing.rdl");
definition = new Byte[stream.Length];
stream.Read(definition, 0, (int) stream.Length);
stream.Close();
}
catch(IOException e)
{
Console.WriteLine(e.Message);
}
try
{
warnings = rs.CreateReport(name, "/", false, definition, null);
if (warnings != null)
{
foreach (Warning warning in warnings)
{
Console.WriteLine(warning.Message);
}
}
else
Console.WriteLine("Report: {0} created successfully with no warnings", name);
}
catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
}
精彩评论