简体   繁体   English

C#Rest API返回ServerReport作为响应

[英]C# Rest API return ServerReport as response

I have one report service which supposed to return SSRS report. 我有一个报告服务,应该返回SSRS报告。 There are several layers in my project. 我的项目有几个层次。

Code: 码:

API Contract: IReport.cs API合约: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 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 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. 我的问题是我在_report中获取ReportId,但其他属性SSRSReport(ServerReport的类型)却为null。 From service it is returning both SSRSReport and ReportId but in result SSRSReport become null. 从服务返回SSRSReport和ReportId,但结果SSRSReport变为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 您可以使用SSRS SOAP API来访问SSRS的所有功能,请参阅使用SOAP集成Reporting Services访问SOAP API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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