This article is intended to explain the steps of WCF windows hosting and consuming service APIs to client side.
WCF (Windows Communication Foundation) is a technology of Microsoft that is being used to implement and deploy Service Oriented Architecture (SOA). Services can be hosted to different location or on different machine and client can consume hosted services in the form of APIs. Services can be consumed by multiple clients. WCF provides the following four common ways of Hosting:
I will not explain the detailed features, hosting, advantages and disadvantages of WCF, but I will explain the way of Windows hosting and consuming step by step. Step 1: Create WCF Service Application. WCF Service Application provides to create Operation Contract, Service Contract, Data Contract, etc. Operation contract provides methods those are being exposed to client side. The following are the steps to create WCF Service Application:
Step 2: Create WCF Window Service Project. I will explain the concept of WCF Windows hosting, so this project will contain the contract and endpoint details and it will be installed in the form of windows service. The following are the steps to create and host WCF window service:
Step 3: Consume WCF Service to Client Side. Client can consume services of hosted windows services in the form of APIs. The following are the steps to consume APIs:
Folder structure is like the following: See the attached code.
Learning WCF: Practical Implementation