?
Solved

WCF webservice OR .net webservice

Posted on 2012-09-19
3
Medium Priority
?
593 Views
Last Modified: 2012-09-26
I have  created a .net website which calls SSRS web service with a report name, and parameter, generates the report as a pdf document and saves it on a file server. This part is just for learning to use SSRS webservice to generate reports.

I now want to create my Reporting Web Service that will take an rdl file name and the parameter values to to run the report on  a predefined report server to generate the report in pdf format and return byte array for the file to the client.

Example: I have a report called CustomersByRegion on my report server that takes regionID as a parameter. The report shows all the customers in that region.

Now using my Reporting web service I want to be able to pass the rdl name 'CustomersByRegion' and RegionID 101, so this web service will use the SSRS web service to run the report with this parameter, generate a byte array for a pdf and return the byte array.

Is this possible? Do I need to create a WCF web service for this purpose or just a .net web service?

Thanks.
0
Comment
Question by:patd1
  • 2
3 Comments
 
LVL 18

Assisted Solution

by:DarrenD
DarrenD earned 1500 total points
ID: 38416909
Hi,

Yes this is possible to do and you should use WCF.

You need to create a service contract that returns a byte array or Stream and then call your method to create the pdf from SSRS and then simply return the byte array.

Have a review of this for Stream
http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

and this for byte[]...
http://www.codeproject.com/Articles/37651/WCF-Large-File-Download-Upload-Service

Cheers,

Darren
0
 

Accepted Solution

by:
patd1 earned 0 total points
ID: 38423056
I added byte[] GenerateSSRSReport(string memberID) operation to my wcf service

I also added service reference (as I did not see an option to add web reference) to myserver/ReportExecution2005.asmx?WSDL and /ReportService2005.asmx?WSDL

Now when I bring CreateReport code from my web application where it was working fine, I get several compilation errors in this method. I have marked these in the code. Please guide on how to resolve.  Thank You.

namespace MyReportService
{
    [DataContract]
    public class MyFaultException
    {
        private string _reason;
        [DataMember]
        public string Reason
        {
            get { return _reason; }
            set { _reason = value; }
        }
    }

    class DSCC_ReportService : IDSCC_ReportService
    {
        #region IMyReportService Members

        public byte[] GenerateSSRSReport(string memberID)
        {
            byte[] ReportLetter = CreateReport(memberID);
            return ReportLetter;
        }
        #endregion
  
public static byte[] CreateReport(string member)
        {
            string memberID = member;
           

            //RS2005.ReportingService2005 rs;  //compilation error in these 4 lines, so changed it to the code that follows  after these 4 lines commented out.
            //RE2005.ReportExecutionService rsExec;
            //rs = new RS2005.ReportingService2005();
            //rsExec = new RE2005.ReportExecutionService();

  RS2005.ReportingService2005SoapClient rs;
            RE2005.ReportExecutionServiceSoapClient rsExec;

            rs = new RS2005.ReportingService2005SoapClient();
            rsExec = new RE2005.ReportExecutionServiceSoapClient();            
           

            string deviceInfo = null;
            string format = "pdf";
            Byte[] results;
            string encoding = String.Empty;
            string mimeType = String.Empty;
            string extension = String.Empty;
            RE2005.Warning[] warnings = null;
            string[] streamIDs = null;

            string reportName = @"/Data Mgmt/Sample HAP Letter";
            string historyID = null;
            bool forRendering = false;
            RS2005.ParameterValue[] _values = null;
            RS2005.DataSourceCredentials[] _credentials = null;
            RS2005.ReportParameter[] _parameters = null;

           _parameters = rs.GetReportParameters(reportName, historyID, forRendering, _values, _credentials);  /compilation error here, not sure what to do. please guide.
                RE2005.ExecutionInfo ei = rsExec.LoadReport(reportName, historyID); //compilation errors
                RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[1];

                if (_parameters.Length > 0)
                {
                    parameters[0] = new RE2005.ParameterValue();
                    parameters[0].Label = "MemberID";
                    parameters[0].Name = "MemberID";
                    parameters[0].Value = memberID; 
                }
                rsExec.SetExecutionParameters(parameters, "en-us"); //compilation error

                results = rsExec.Render(format, deviceInfo,
                          out extension, out encoding,
                          out mimeType, out warnings, out streamIDs);
                return results;     

        }

Open in new window

0
 

Author Closing Comment

by:patd1
ID: 38435956
Problem solved. Found the advanced tab on add serveic reference diaglogue, where I can add web refefrenc and the whole thing works.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month16 days, 17 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question