Introduction:
I have SQL Server Express 2008 R2 installed with Advanced Services. I have created few reports using BI Design Studio and deployed them to the Server. If I access the reporting server using IE (http://Ser2008/Reports/) it works fine (I have to put in User Name/Password). I can view reports or fool around with the settings.
Problem:
On my local machine I created a winforms application with one form containing a ReportViewer control. On form load I'm running following code:
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials =
new CustomCredentials("secret@123") {
UserName = "administrator",
Domain = "ser2008"
}.NetworkCredentials;
reportViewer1.ServerReport.ReportServerUrl = new Uri("http://ser2008/Reports/");
reportViewer1.ServerReport.ReportPath = "/Students/Attendance";
var l = new List<ReportParameter>();
l.Add(CreateParameter("UserId", "144"));
l.Add(CreateParameter("Class", "8"));
l.Add(CreateParameter("date_from", "2011-09-04"));
l.Add(CreateParameter("date_to", "2011-12-31"));
reportViewer1.ServerReport.SetParameters(l); //EXCEPTION THROWN HERE
reportViewer1.RefreshReport();
I get following exception:
The attempt to connect to the report server failed. Check your connection
information and that the report server is a compatible version. The request
failed with HTTP status 404: Not Found.
The stack trace is as follows:
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005
.Execution.RSExecutionConnection.MissingEndpointException
.ThrowIfEndpointMissing(WebException e)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005
.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn]
(RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.
Execution.RSExecutionConnection.LogonUser(String userName, String password, String authority)
at Microsoft.Reporting.WinForms.ServerReport.get_Service()
at Microsoft.Reporting.WinForms.ServerReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.ServerReport.SetParameters(IEnumerable`1 parameters)
at GridEditor.ReportViewerForm.btnRefresh_Click(Object sender, EventArgs e)
in D:\TestApp\ReportViewerForm.cs:line 79
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager
.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at GridEditor.Program.Main() in D:\TestApp\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback
, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
CustomCredentials:
public class CustomCredentials : IReportServerCredentials
{
public string UserName { get; set; }
public SecureString Password { get; set; }
public string Domain { get; set; }
#region ctor
public CustomCredentials(string password)
{
Password = new SecureString();
foreach (char c in password.ToCharArray())
Password.AppendChar(c);
}
#endregion
#region IReportServerCredentials Members
public bool GetFormsCredentials(out Cookie authCookie, out string userName
, out string password, out string authority)
{
throw new NotImplementedException();
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get { throw new NotImplementedException(); }
}
public System.Net.ICredentials NetworkCredentials
{
get { return new NetworkCredential(UserName, Password, Domain); }
}
#endregion
}
UPDATE:
I have found following exception also in some place in my log file:
System.Web.Services.Protocols.SoapException: The path of the item
'/Students/Attendance/_vti_bin/ListData.svc/$metadata' is not valid. The full
path must be less than 260 characters long; other restrictions apply. If the
report server is in native mode, the path must start with slash. --->
Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException:
The path of the item '/Students/Attendance/_vti_bin/ListData.svc/$metadata' is
not valid. The full path must be less than 260 characters long; other
restrictions apply. If the report server is in native mode, the path must
start with slash.
at Microsoft.ReportingServices.WebServer.ReportingService2005Impl
.GetPermissions(String Item, String[]& Permissions)
In the end it was all trivial detail 8-)
I was using Report Manager
url (http://ser2008/Reports/) where I was to use Report Server
url (http://ser2008/ReportServerXp/).