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.
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