Pages

Men

rh

6/09/2012

Hosting a Service on an IIS Web Server

Hosting a Service on an IIS Web Server:-
Hosting a service on an IIS Web Server is very similar to hosting a traditional Web service( with an .asmx file extension). Services exposed this way will be highly available and scalable, but they will require installation  and config2008 uration on IIS Web server.

Service hosted with IIS 5.1 are limited to using the same port number, thus restricting the number of host process that can execute concurrently. Services hosted with any version can run side by side with earlier Asp.net application and thus be integrated easily with existing web services. Unfortunately, they all are restricted using the HTTP Protocol.

The easiest way to host the a service by using IIS is to use the built in template with Visual Studio to create a new Web service To do this, in Visual Studio 2008, choose New and then Web site from the File Menu. Select WCF service as the template as  the template. Visual Studio creates Virtual Directory in  which you can  place your service code files. the virtual directory maps to location on the Windows file system for the web server. The template will also create the sub directories and configuration files you need.

Before creating a  web site, ensure that the IIS is installed and configured on the Web server and then the WCF HTTP activation component is installed. If you install .NET Framework 3.5 after IIS is installed, you do not need to perform any additional steps. Otherwise you must register WCF with IIS and Asp.net.

Service hosted in IIS require the creation of a file with an .svc file extension. this is done for automatically if you use Visual Studio 2008 WCF Service template. The Service .svc file is an XML based file that must include as @ServiceHost directive. The directive identifies your service and it should include attributes that identify the service code language and the name of the service.

For example if you want to host a service named Orderservice that uses C# code, you could use a directive such as the following.

<% @ServiceHost Language="C#" service="OrderService" %>

If you use Visual Studio 2008 template to create your IIS Service host, a file named Service.svc will be added automatically to the application directory. This file already contains an @ServiceHost directive, so you need only edit the attributes to match your environment .

Disadvantages  of using IIS to host a Service:
using IIS to host your services means that you will not be able to support  non HTTP Protocols such as TCP, named pipes and MSMQ.

Which file specifies the types that your service will expose in IIS?
Service type are exposed through IIS by using the service file. The file must have .svc file extension and should reside  in the application directory for your IIS hosting application. This file included @ServiceHost directive, which specifies the service name and language for the service code files. These files should included in an App_Code subdirectory.


No comments :

Post a Comment