1. wcf-was-hosting

WAS Hosting - (WCF)

Windows Process Activation Service (WAS) hosting is a method of hosting Windows Communication Foundation (WCF) services in IIS. WAS hosting is ideal for environments that require high levels of scalability and availability.


To host a WCF service using WAS hosting, you will need to configure IIS to use the WAS listener adapter. Here is a sample configuration file for WAS hosting:

      <service behaviorConfiguration="MyServiceBehavior" name="MyService">
        <endpoint address="" binding="wsHttpBinding" contract="IMyService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="http://localhost/MyService" />
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
      <add name="svc-Integrated" path="*.svc" verb="*" modules="ProtocolSupportModule" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <add value="MyService.svc" />


Here's an example of how to configure IIS to use WAS hosting for a WCF service:

  1. Install IIS and the WAS feature on your server or development machine.
  2. Open IIS Manager and create a new website or application.
  3. Copy the configuration file above into an empty file named web.config in the root directory of your website or application.
  4. Create a new WCF service file named MyService.svc in the root directory of your website or application, with the following contents:
<%@ ServiceHost Language="C#" Debug="true" Service="MyService" CodeBehind="MyService.svc.cs" %>
  1. Create a new code file named MyService.svc.cs in the same directory, with the following contents:
using System.ServiceModel;

public interface IMyService
  string GetMessage();

public class MyService : IMyService
  public string GetMessage()
    return "Hello, World!";
  1. Save and close all files, and then browse to your website or application to verify that the service is working.


When you browse to your website or application, you should see a page that displays the default document specified in the web.config file, and should be able to access the WCF service by appending /MyService.svc to the URL. For example:



In the sample configuration file and example code, we define a WCF service with a single operation that returns a simple string. We use the DataContract and DataMember attributes to specify the data contract for the operation, and use ServiceBehavior, Endpoint, and Host elements to configure the service behavior, endpoints, and host address. In the example, we also create a separate code file for the service implementation, and use the ServiceHost directive to specify the type of service to host. In IIS, we use the web.config file to specify the service metadata, behavior, and endpoints, and use the WAS listener adapter to process incoming messages.


WAS hosting is well-suited for hosting WCF services in IIS, especially in environments that require scalability and availability. Using WAS hosting, you can take advantage of the built-in IIS features, such as authentication, authorization, and security, to protect your services and control access.

Important Points

  • WAS hosting is a method of hosting WCF services in IIS that provides scalability and availability.
  • You can use the web.config file to specify the service metadata, behavior, and endpoints for your WCF service.
  • You can use the WAS listener adapter to process incoming messages for your WCF service.


In this page, we discussed how to host WCF services using WAS hosting in IIS. We covered the syntax, example, output, explanation, use, important points, and summary of using WAS hosting for WCF services. WAS hosting is a powerful way to scale and host WCF services in IIS, and provides many built-in features for protecting your services and controlling access.

Published on: