I am using SSRS 2008 Reporting Service (http://(server name)/reportserver/reportservice2005.asmx).
Basically, I have 2 applications, one is C# Window Application and another one is C# Window Service.
When I call SSRS Report from C# Window Application then I am able to call RS.CreateDataSource, RS.CreateReport and Render the report in Report Viewer successfully.
But, When I call the same method RS.CreateDataSource or RS.CreateReport through Window Service then its throws error "The request failed with HTTP status 401: Unauthorized.".
I tried to figure out this issue through Fiddler that, what is the issue with window service when we make the call RS.CreateDataSource() method?
And we saw the difference between Direct UI App call and Service call is missing Authorization. In direct UI App call, there is Authorization key present in Headers but missing Authorization key in Service call.
We are using credentials as (RS.Credentials = System.Net.CredentialCache.DefaultCredentials;) in both UI and Service call.
There is sample code: Exactly Same code is in both places (C# Window Application and C# Window Service)
public class SSRSReportsGenerator: MarshalByRefObject, ISSRSReports
{
// Creating Reporting Service Object.
ReportingService2005 RS;
public SSRSReportsGenerator()
{
RS = new ReportingService2005();
RS.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
public void CreateDataSource()
{
string name = "DataSource1";
string parent = "/MTVN Reports";
// Define the data source definition.
DataSourceDefinition definition = new DataSourceDefinition();
RS.Credentials = System.Net.CredentialCache.DefaultCredentials;
RS.UseDefaultCredentials= false;
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
definition.UserName = "sa";
definition.Password = "sa123";
definition.ConnectString = "";
definition.Enabled = true;
definition.EnabledSpecified = true;
definition.Extension = "DATASET";
definition.ImpersonateUser = false;
definition.ImpersonateUserSpecified = false;
definition.Prompt = null;
definition.WindowsCredentials = false;
try
{
RS.CreateDataSource(name, parent, true, definition, null); // Getting error on this line
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
Please Help !!