Код работает нормально при запуске приложения CRM2011.Когда я встраиваю свой код в CRM, он вернет пустой PDF-файл без данных.
мой код
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;
}
Спасибо