In Focus

Create WCF Service In Visual Studio 2017

This blog explains how to create a WCF service in Visual Studio 2017.

Before starting your new WCF service and if you want to know more about WCF, please refer to my blog WCF - Windows Communication Foundation.
 
Step 1 - Create a WCF service application
  1. On the File menu, point to New and then click "Project".
  2. In the New Project dialog box, expand the Visual Basic or Visual C# node and click WCF, followed by WCF Service Application.
  3. Provide the project name, such as WCFService or another as you wish, and specify the location.

    Create WCF Service In Visual Studio 2017

  4. Click OK to open the project.

    The Solution Explorer will look like the following screen.

    Create WCF Service In Visual Studio 2017
In the preceding Solution Explorer, you have seen three files I have highlighted in a blue box. They are -

IServices1.cs

We call it Contract in WCF. This file holds the interfaces that are declared under the Service contract and method signatures that are declared under the Operation contract in WCF.

Create WCF Service In Visual Studio 2017
 
Service1.svc
 
This is a class file where IServices1.cs interfaces are implemented. The whole logic is written here. 

Create WCF Service In Visual Studio 2017
 
Web.Config
 
In a WCF application, Web.config files play another important role, as the application will have various sets of “ABC”- Address, Binding, and Contract and all those are defined in the web.config files.

Create WCF Service In Visual Studio 2017
 
Step 2 - Run the WCF application
 
Set the Service.SVC file as the “Start up page” and run the application. Now, the WCF Test client window will be displayed.

Create WCF Service In Visual Studio 2017
 
Step 5
 
Provide input parameters and click on the "Invoke" button for a response from the service.
 
Click on the method name, then follow the screenshot steps.
 
Create WCF Service In Visual Studio 2017