Create WCF Web Service in Visual Studio

Leave a comment

Windows Communication Foundation (WCF) web services can be created in Visual Studio. Note these web services replace the old asmx web services.

To create a web service in Visual Studio do the following.

Create a new project in Visual Studio and select WCF Service Application:

This creates the solution:

Delete the existing Service1.svc and IService1.cs and add a new WCF Service:

This will create these 2 files again. Note the file contains the ServiceContract and the OperationContract:

The DoWork method is created as a shell:

We will implement a Hello World web service. Change DoWork() to return a string “Hello World”:

Press F5 and Invoke. The string Hello World is returned:

To test consuming and invoking this through code, let’s create a new console app and add it to the solution:

Select Add Service Reference:

Click Discover to pick up the service created:

Add the following code. Add a using statement for the web service, and create an instance of ServiceClient. Display the Hello World output in the console.

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

Leave a Reply

Your email address will not be published. Required fields are marked *