Sunday, 26 June 2011

WCF Hosting with Different ways


       The host can be provided by Internet Information Services (IIS), by the Windows Activation Service (WAS) on Windows Vista or Windows Server 2008, Windows 7 or later, on the Windows Server AppFabric, or by the developer as part of the application.
       In-process (or in-proc) hosting, where the service resides in the same process as the client, is a special case. By definition, the developer provides the host for the in-proc case.

IIS 5/6 Hosting

       The main advantage of hosting a service on the Microsoft IIS web server is that the host process is launched automatically upon the first client request, and IIS 5/6 manages the lifecycle of the host process.
       The main disadvantage of IIS 5/6 hosting is that you can only use HTTP.
       With IIS 5, you are further restricted to having all services use the same port number.
       Hosting in IIS is very similar to hosting a classic ASMX web service.
       You need to create a virtual directory under IIS and supply an .svc file.
       The .svc file functions similarly to an .asmx file and is used to identify the service code behind the file and class.

Using Visual Studio 2010

       You can use Visual Studio 2010 to generate a boilerplate IIS-hosted service.
       From the File menu, select New Web Site, then select WCF Service from the New Web Site dialog box. Visual Studio 2010 creates a new website, a service code, and a matching .svc file.
       You can also use the Add New Item dialog box to add another service later.

Self-Hosting

       Self-hosting is the technique in which the developer is responsible for providing and managing the lifecycle of the host process.
       Use self-hosting when you want a process (or machine) boundary between the client and the service and when you are using the service in-proc—that is, in the same process as the client.
       You can provide any Windows process, such as a Windows Forms application, a WPF application, a Console application, or a Windows NT Service.
       You can provide a host with only a few lines of code.
       A self-hosted service can use any WCF transport protocol, and you can take advantage of all the WCF features, including the service bus, discovery, and utilize a singleton service.
       Hosting application config file (app.config) typically lists the types of the services you wish to host and expose to the world.
       You need to provide the constructor of ServiceHost with the service type and optionally with default base addresses.
       The set of base addresses can be an empty set, and even if you provide base addresses, you can configure the service to use different base addresses.
       Having a set of base addresses enables the service to accept calls on multiple addresses and protocols and to use only a relative URI.


WAS Hosting

       The problem with hosting in IIS 5/6 is that it is a web server, not a hosting engine.
       It therefore requires you to masquerade your service as a website
       While ASP.NET encapsulates this step for you, it causes a significant increase in internal complexity, involving the HTTP modules and the ASP.NET pipeline.
       The problem is that the more moving parts involved, the higher the likelihood of something going wrong.
       As a result, hosting in IIS 5/6 is notorious for instability and the frequent need to reset the server or IIS 5/6. Moreover, limiting the service to using only HTTP makes IIS 5/6 ill-suited for intranet applications.







1 comments :

HostGator Hosting Reviews said...

Thanks for sharing such a good information...

Post a Comment