locked
Create report object in .asmx RRS feed

  • Question

  • User1652530521 posted

    Hi,

    Is it possible to call a report from .asmx and create a pdf file automatically?

    I managed to do it in a normal web form but my boss wants to do it from .asmx.

    In the web form I added a reportviewer but not sure how to do it from webservice.

    Thanks

    Thursday, August 27, 2015 2:17 AM

Answers

  • User1644755831 posted

    Hello whisky,

    Have you tried adding reference to Mircosoft.ReportViewer.WebForms in the webservices. I did a quick test and I want able to create an instance on Report Viewer in webservice.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using Microsoft.Reporting.WebForms;
    
    namespace WebApplication1
    {
      /// <summary>
      /// Summary description for WebService1
      /// </summary>
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      // [System.Web.Script.Services.ScriptService]
      public class WebService1 : System.Web.Services.WebService
      {
    
        [WebMethod]
        public string HelloWorld()
        {
    
          ReportViewer rp = new ReportViewer();
          return "Hello World";
        }
      }
    }
    

    Then use LocalReport.Render Method to generate pdf.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 28, 2015 1:49 AM