Search code examples
reportingservices-2005dynamics-crm-2011

Why I am getting blank pdf Inside CRM2011(CRM 2011 Blank PDF Problem)?


The code working fine when run out side the CRM2011 application. When I embedded my Code Inside the CRM it will return blank pdf file with no data.

following is my code

public static Byte[] RenderReport(string ServiceURL, string ReportName, ParameterValue[] parameters)
    {
        byte[] result;
        string encoding;
        string mimeType;
        Warning[] warnings = null;
        string[] streamids;
        string extension;

        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
        binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
        binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
        binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
        binding.Security.Transport.Realm = string.Empty;
        binding.MaxReceivedMessageSize = 2147483647;
        string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
        EndpointAddress endpoint = new EndpointAddress(ServiceURL);

        ReportExecutionServiceSoapClient client = new ReportExecutionServiceSoapClient(binding, endpoint);

        client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;


        ExecutionInfo execInfo = new ExecutionInfo();
        ExecutionHeader execHeader = new ExecutionHeader();
        ServerInfoHeader serverInfoHeader;

        ExecutionInfo executionInfo;
        ExecutionHeader executionHeader = client.LoadReport(null, ReportName, null, out serverInfoHeader, out executionInfo);
        // Attach Report Parameters
        //executionHeader.ExecutionID = executionInfo.ExecutionID;
        if (parameters != null)
            client.SetExecutionParameters(executionHeader, null, parameters, null, out executionInfo);
        ServerInfoHeader Info= client.Render(executionHeader, null, "PDF", deviceInfo, out result, out extension, out mimeType, out encoding, out warnings, out streamids);

        return result;
    }

Thanks


Solution

  • I changed the Async processor to run under a user that has access to the Report Server database and it worked instantly.it was set to use network service so I changed it to Administrator in services.