Introduction
For a WCF service to be available for the clients to consume, we need to host the WCF service. I highly recommend reading the previous parts:
No code is required to host a WCF service, there is no need to write code to instantiate and start the service host, as is the case with self-hosting. Automatic message based activation of IIS provides automatic message-based activation. This means that the service can be activated on demand. When a message arrives at the service, it then launches itself and fulfils the request. In case of self-hosting, the service should be always be running.
Step 1
Creating WCF Service
- Open Visual Studio.
- Go To File -> New Project.
- Select WCF Service Application.
- Provide it a name like "SquareService".

Figure 1: SquareService
- Delete the default created Service1.cs and Service1.svc file.
- Add a new svc file as ini the following and name it SquareService, then right-click on the application and select Add -> New Item and Select WCF Service.

Figure 2: WCF Service

Figure 3: WCF Service1
- Replace the following code in the ISquareService interface.
With:- [ServiceContract]
- public interface ISquareService
- {
- [OperationContract]
- void DoWork();
- }
- [ServiceContract]
- public interface ISquareService
- {
- [OperationContract]
- int GetSqaure(int num);
- }
- Replace the following code in the SquareService.svc file:
- public void DoWork()
- {
- }
- With: public int GetSqaure(int num)
- {
- return num * num;
- }
- Build the solution.
Step 2
Now to set up to publish the service to be hosted in IIS.




















Sonu ChaudharyPosted Apr 4, 2016, 12:52 PM
nice artical
Arul RPosted Nov 4, 2015, 5:09 AM
Good one !!!
Santhakumar MunuswamyPosted Jul 11, 2015, 3:14 AM
Good article! Thanks for sharing
Rakesh KalluriPosted Jul 9, 2015, 8:20 AM
Nice post...
Debasis SahaPosted Jul 9, 2015, 3:24 AM
Good one..
Sibeesh VenuPosted Jul 9, 2015, 1:37 AM
Good one. Thanks for sharing :)\
Gopi ChandPosted Jul 9, 2015, 1:12 AM
Well done
Jaipal ReddyPosted Jul 9, 2015, 12:42 AM
Good work Sir.