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.
Consume a Custom WCF Service in a Console Application
Let's Play Around With Channel Factory in WCF Service Hosted on Web App
Thanks everyone:-)
great work.
Hi Vijay it's a great effort to accomplish such task keep it up thanks for sharing.....
Nice article.
keep posting