Introduction: Hosting of WCF Services.

In this, we describe various types of hosting in WCF Services and what are the limitations of Hosting a WCF Service.

Types of Hosting in WCF Services:

  1. IIS Hosting
  2. Self Hosting

IIS Hosting:

  • In this technigue, Host Process is launched automatically upon the first request of the client.
  • Host Process life cycle is managed by IIS.

Disadvantage of IIS Hosting:

  1. Only HTTP Protocol used.
  2. All the sevice will run on the same port.

Self Hosting:

  • It needs to add a managed code to host the process.
  • The managed code could be either a Windows form application or Console application.
  • Mainly Console applications are used for the purpose of self hosting.
  • Here host process must be running before client makes a call to the service.
  • The Console/Windows application must specifically create and open an instance of ServiceHost object.
  • The ServiceHost then remains open and available until it is no longer needed.

Code:

Sub Main()
' Create and open the host.
Using myServiceHost As New _
ServiceHost(GetType(WcfMathService.MyCalc))
myServiceHost.Open()

' Just to keep the host alive.
Console.WriteLine("Hit Enter to shut down host")
Console.ReadLine()
End Using
End
Sub

Limitations of Hosting of WCF Service:

  1. WCF service cannot exist in Void.
  2. Every WCF service must be hosted in a Windows process called the Host process.