ActiveReports 12 Server User Guide
Uploading a Code-Based Section Report
ActiveReports 12 Server User Guide > Samples and Walkthroughs > Walkthroughs > Uploading a Code-Based Section Report

You can upload all types of developer-created ActiveReports to the server using the UploadResource method. This topic explains how to upload a code-based section report.

  1. From the Visual Studio File menu, select New Project.
  2. In the New Project dialog that appears, select Visual C# or Visual Basic from the template list, click Windows and  select Console Application.
  3. Rename the project to UploadReport and click OK.
    Note: The target framework of the project must be set to .NET Framework 4.5 or above.
  4. From the Visual Studio Project menu, select Add Service Reference.
  5. In the Add Service Reference dialog that appears, enter the following address in the Address field.
    Paste in the Address box, replacing 8080 with the site port where you installed ActiveReports 12 Server.
    Copy Code
    http://localhost:8080/ReportService.svc
  6. Click Go, and when the ReportService appears in the Services pane, you can expand it and select the service interface to reveal its available operations in the pane to the right.
  7. Rename the Namespace that you want to use to ReportService and click OK. The reference appears in the Solution Explorer.
  8. Open the app.config file and in the address attribute of the endpoint element, check whether the service address set in step 5 is correct. Replace the address if it is not correct. 
    Confirm the value of address attribute in the endpoint element of the app.config file
    Copy Code
    <client>
    <endpoint address="http://localhost:8080/ReportService.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IReportService"
    contract="ReportService.IReportService" name="WSHttpBinding_IReportService" />
    </client>
    Note: The service address may not get updated automatically by the server configuration of the installed ActiveReports Server.
  9. In Program.cs or Module1.vb, add the following statements to the using/Imports statements at the top of the code.

    Visual Basic

    Visual Basic code (Add to the list of Imports statements at the top of the code.)
    Copy Code
    Imports System.IO
    Imports UploadReport.ReportService                           
    

    C#

    C# code(Add to the list of using statements at the top of the code.)
    Copy Code
    using System.IO;
    using UploadReport.ReportService;                                       
    
  10. In Program.cs or Module1.vb, add the following code into the Main method.

    Visual Basic

    Visual Basic code (Paste the following code into the Main method of the Module1 module declaration)
    Copy Code
    Dim filepath As String = "C:\section_report.rpx"
    Dim serverUserName = "USER"
    Dim serverUserPwd = "PASS"
    Dim uploadOptions = New UploadOptions() With { _
        .Overwrite = True _
    }
    Dim reportService = New ReportServiceClient("WSHttpBinding_IReportService")
    Dim securityToken = reportService.Login(serverUserName, serverUserPwd, Nothing, True)
    
    ' Name: Report name to display after the upload.
    ' ReportType: Type of the report to upload.
    ' ClassName: Class name. Specify while uploading code-based section report.
    ' AssemblyResourceId: Assembly Resource ID. Specify while uploading code-based section report.
    Dim reportDescription As New ReportDescription()
    With reportDescription
        .Name = "Test Report"
        .ReportType = ReportType.SectionReport
        .ClassName = Nothing
        .AssemblyResourceId = Nothing
    End With
    reportService.UploadResource(securityToken, ReportDescription, Convert.ToBase64String(File.ReadAllBytes(filepath)), UploadOptions)                         
    

    C#

    C# code (Paste the following code into the Main method of the Program class declaration)
    Copy Code
    string filepath = @"C:\section_report.rpx";
    var serverUserName = "USER";
    var serverUserPwd = "PASS";
    var uploadOptions = new UploadOptions { Overwrite = true };
    var reportService = new ReportServiceClient("WSHttpBinding_IReportService");
    var securityToken = reportService.Login(serverUserName, serverUserPwd, null, true);
    
                                            
    // Name: Report name to display after the upload.
    // ReportType: Type of the report to upload.
    // ClassName: Class name. Specify while uploading code-based section report.
    // AssemblyResourceId: Assembly Resource ID. Specify while uploading code-based section report.
    var reportDescription = new ReportDescription()
    {
        Name = "Test Report",
        ReportType = ReportType.SectionReport,
        ClassName = null,
        AssemblyResourceId = null
    };
    reportService.UploadResource(securityToken, reportDescription, Convert.ToBase64String(File.ReadAllBytes(filepath)), uploadOptions);                   
    
  11. Run the project.
See Also