In this article you will see how to consume the custom WCF service in a Console Application. SQL database details Employee_Details table has the following data: I have created a custom WCF service and hosted it in IIS http://localhost:9002/EmployeesService/EmployeesService.svc which is used to fetch the data from the above SQL database table for the specified id. Syntax public Employee_Detail getEmployeebyId(int empId) Return Value Type: EmployeesWCFService.Employee_Detail You will get the following result for the specified id 102: Example Create a Console application Steps Involved
namespace ConsumeCustomWCF { class Program { static void Main(string[] args) { EmployeesServiceClient serviceClient = new EmployeesServiceClient(); EmployeesServiceReference.Employee_Detail emp = serviceClient.getEmployeebyId(102); Console.WriteLine(emp.EmpId); Console.WriteLine(emp.EmployeeName); Console.WriteLine(emp.EmployeeDesignation); Console.WriteLine(emp.Dept); Console.WriteLine(emp.WorkLocation); Console.ReadLine(); } } }
Build the solution.
Hit F5.
Output:
Summary Thus in this article you have seen how to consume a custom WCF service in a Console application.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: