开发者

How to specifiy proxy settings for SSRS Winforms Control

I am using the 开发者_StackOverflowSSRS WinForms client control to display reports in an app. User's behind proxies are getting a 407 (proxy authentication) error. How do I specify proxy settings for the request? i.e. proxy server, username & password. I was expecting it to be similar to the HttpRequest and WebProxy.

This is helpful C# Connecting Through Proxy however I need to specify proxy settings on a per SSRS request basis.

Any ideas?

Thanks.


You can specify the proxy settings by using reporting web services.

  • Add the reporting web reference to your project. The URL of the web service is :

http://servername/ReportServer/ReportExecution2005.asmx

  • In the code calling the web service.

    byte[] report = null;

            //create an instance of the reporting service web reference
            var reportReference = new ReportExecutionService();
    
            <strong>//Set your proxy settings
             reportReference.Proxy = new WebProxy("address:port");
    
    
            //create a credential that will be used to authenticate again the
    

    reporting services var credential = new NetworkCredential("username", "password", "domainName");

            reportReference.Credentials =
    

    credential;

            reportReference.PreAuthenticate =
    

    true;

            //the virtual path to the report
            string virtualPath = "/Folder/ReportName";
    


            //Specify the device info
            string deviceInfo =
                "<DeviceInfo><Toolbar>False</Toolbar><Parameters>False</Parameters><DocMap>True</DocMap><Zoom>100</Zoom></DeviceInfo>";
    
            //Create an array of parameters, for example our report needs 2 parameters
            var parameters = new ParameterValue[2];
    
            //Specify the value for the parameter
            var startDateParameter = new ParameterValue();
            startDateParameter.Name = "StartDate";
            startDateParameter.Value = "01/01/2008";
    
            parameters[0] = startDateParameter;
    
            var endDateParameter = new ParameterValue();
            endDateParameter.Name = "EndDate";
            endDateParameter.Value = "31/12/2008";
    
            parameters[1] = endDateParameter;
    
            //Create variables for the remainder of the parameters
    
            string extension = string.Empty;
    
            ExecutionHeader executionHeader = null;
    
            reportReference.ExecutionHeaderValue =
    

    executionHeader;

            reportReference.LoadReport(virtualPath,
    

    null);

            reportReference.SetExecutionParameters(parameters,
    

    "en-AU");

            try
            {
                //Execute the report
                string[] streamIDs;
                Warning[] warning = null;
                string encoding;
                string mimeType;
                string format = "PDF";
    
    
                <strong>//Execute the report
                report = reportReference.Render(format,
    

    deviceInfo, out extension, out mimeType, out encoding, out warning, out streamIDs);

                using (var fileStream = new FileStream("myReport.PDF", FileMode.Create))
                {
                    fileStream.Write(report, 0,
    

    report.Length);

                    fileStream.Close();
                }
    

    > Process.Start("myReport.pdf");

            }
            catch (SoapException exception)
            {
    


    }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜