CRM 2011 – Render SSRS Report from Plugin

Recently I had to play with SSRS web services. The objective was to render multiple reports in pdf format from within a CRM 2011 plugin, and to upload the files either in notes or in Sharepoint document location. After doing a lot of research, here is the function I came up with to call the SSRS web service. All of it does not completely make sense, and I had a hard time putting this all together. Documentation is not easy to find and understand.


private Byte[] RenderReport(string serviceURL, string reportPath, 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 = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;

ExecutionInfo executionInfo;
ExecutionHeader executionHeader;
ServerInfoHeader serverInfoHeader;

executionHeader = client.LoadReport(null, reportPath, null, out serverInfoHeader, out executionInfo);
executionHeader.ExecutionID = executionInfo.ExecutionID;

if (parameters != null)
client.SetExecutionParameters(executionHeader, null, parameters, “en-us”, out executionInfo);

ServerInfoHeader Info = client.Render(executionHeader, null, “PDF”, deviceInfo, out result, out extension, out mimeType, out encoding, out warnings, out streamids);

return result;

2 Replies to “CRM 2011 – Render SSRS Report from Plugin”

Leave a Reply

Your email address will not be published. Required fields are marked *