Creating and Accessing WCF Services

.Net Developer
3 min readJan 1, 2020

Following steps will show you to create a WCF Service and access them thorough the Client Application.

To create WCF Service

1. Open Visual Studio 2010 and On the File menu, point to New and then click Project.

2. In the New Project dialog box, expand the Visual C# node and click WCF, followed by WCF Service Library. Give Name to your Service and Click OK to open the project.

Now, you will find two file in your project Solution Explorer, named IService1.vb and IService1.cs.

Testing the Service

To test a WCF Service

1. Press F5 to run the service. A WCF Test Client form will be displayed and it will load the service.

2. In the WCF Test Client form, double-click the GetResult() method under IService1. The GetResult tab will be displayed.

· Select the Value field of Operation and type “Add” or “Subtract” or “Multiply” or “Divide”.

· Select the Value field of Num1 and type any Number.

· Select the Value field of Num1 and type any Number

4. Click the Invoke button. If a Security Warning dialog box is displayed, click OK. The result will be displayed in the Response box.

5. On the File menu, click Exit to close the test form.

Accessing the Service

To reference a WCF service

1. On the File menu, point to Add and then click New Project.
2. In the New Project dialog box, expand the Visual C# node and select Windows, and then select Windows Forms Application. Click OK to open the project.
3. Right-click WindowsApplication1and click Add Service Reference. The Add Service Reference dialog box will appear.
4. In the Add Service Reference dialog box, click Discover. Service1 will be displayed in the Services pane.
5. Click OK to add the service reference.

Testing the Service (To build a client application)

2. Now, Double-Click on the Get Result Button and Add the following code on Click-Event of the Get Result Button.

3. Enter the Required values in the Fields and Click on Get Result Button to get the Result.

Output Window

Last updated:1/20/2021 1:46:11 AM

Originally published at https://www.mindstick.com on January 1, 2020.

--

--

.Net Developer

I’m a professional Technical writer and Software Development with more than 5 years of experience.