简体   繁体   中英

C# Rest API return ServerReport as response

I have one report service which supposed to return SSRS report. There are several layers in my project.

Code:

API Contract: IReport.cs

[ServiceContract]
[ServiceKnownType(typeof(ServerReport))]
[ServiceKnownType(typeof(ReportDTO))]
public interface IReport
{
    [OperationAttribute("GetReportControls", OperationType.GET)]
    List<ReportControlDTO> GetReportControls(int UserReportId, string Culture);

    [OperationAttribute("GetReportNames", OperationType.GET)]
    List<ReportNameDTO> GetReportNames(int RoleId);

    [OperationAttribute("GetReportQuery", OperationType.GET)]
    ReportQueryDTO GetReportQuery(int ReportId, string SelectedValue, string SelectedGroup, string Culture, int TimezoneOffset);


    [ServiceKnownType(typeof(ServerReport))]
    [OperationAttribute("GetReport", OperationType.GET)]
    ReportDTO GetReport(int ReportId, string SelectedValue, string SelectedGroup, string Culture, int TimezoneOffset);
}

API : Report.cs

public partial class ReportService : IReport
{

    public List<ReportControlDTO> GetReportControls(int UserReportId, string Culture)
    {
        //code
    }


    public List<ReportNameDTO> GetReportNames(int RoleId)
    {
        //code
    }

    public ReportQueryDTO GetReportQuery(int ReportId, string SelectedValue, string SelectedGroup, string culture, int TimeOffset)
    {
        //code

    }
    public ReportDTO GetReport(int ReportId, string SelectedValue, string SelectedGroup, string culture, int TimeOffset)
    {

        ReportDTO result =new ReportDTO();
        result.SSRSReport=new ServerReport();
        result.ReportId=123;
        return result;
    }


}

ReportDTO.cs

[DataContract]
[Serializable]
public class ReportDTO
{
    [DataMember]
    public ServerReport SSRSReport { get; set; }
    [DataMember]
    public int ReportId { get; set; }
}

I am calling that service using following code:

  var  _report = PlatformAPIProxy.Report.GetReport(ReportId, SelectedVal, SelectedGroup, selectedCulture, TimezoneOffset);

My problem is I am getting ReportId in _report but other property SSRSReport (type of ServerReport) getting null. From service it is returning both SSRSReport and ReportId but in result SSRSReport become null. Is there any solution to return this type of object?

As stated here from Olaf Helper

You can use the SSRS SOAP API to access all features of SSRS, see Integrating Reporting Services Using SOAP and Accessing the SOAP API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM