Samples and Walkthroughs > Walkthroughs > Accessing the Web Service |
This topic explains how to access the ActiveReports 8 Server Web service from a Visual Studio console application.
You can use a console application to create and access the ActiveReports 8 Server Web service.
Steps to create a console application
Steps to add a service reference
Paste in the Address box, replacing 8080 with the site port where you installed ActiveReports 8 Server. |
Copy Code
|
---|---|
http://localhost:8080/ReportService.svc |
Steps to add using directives
Paste at the top of the Program.cs file, replacing ConsoleApplication1.ARS*Service with the name of your application and service namespaces. |
Copy Code
|
---|---|
using ConsoleApplication1.ARSReportService; using ActiveReports.Server.ServiceClients; |
Steps to add code to log in
Paste in the Program.cs file inside the class Program brackets, replacing the default static void Main. |
Copy Code
|
---|---|
private static readonly DefaultClientFactory ClientFactory = new DefaultClientFactory(); static void Main(string[] args) { var server = new Uri("http://localhost:8080"); var userName = "MyUserName"; var password = "MyPassword"; using (var authenticationService = ClientFactory.CreateAuthenticationServiceClient(server)) { var isLogged = authenticationService.Login(userName, password, string.Empty, false); Console.WriteLine(isLogged != null ? "Logged in." : "Wrong user name or password."); } Console.ReadLine(); } |