SharePoint Pals
 | Sign In
Steps to perform WCF Windows Activation Service hosting
by Tarun Kumar Chatterjee 9 Jun 2016
.Net – Technology Specialist
Today  :   1     Total  :    2735

Hosting WCF in Activation service takes many advantages such as process recycling, isolation, idle time management and common configuration system. WAS hosted service can be created using following steps

· Enable WCF for non-http protocols

· Create WAS hosted service

· Enable different binding to the hosted service

Before Start creating the service we need to configure the system to support WAS. Following are the step to configure WAS.

Click Start --> Control Panel --> programs and Features and click 'Turn Windows Components On or Off' in left pane.

Expand 'Microsoft .Net Framework 3.5.1' and enable "Windows Communication Foundation HTTP Activation" and "Windows Communication Foundation Non- HTTP Activation".


Now we will be creating WAS Hosted Service

Start the Visual Studio and click File -- >New -- >Web Site. Select the 'WCF Service Application' click OK.


I have created a service named as MyService, which will have an Add method will accept two integer values as input and return the summation of passing parameters value. Interface implementation of the Service is shown below.

Add a WCF service with the following codes


Below is the WASHostedWCFService interface code:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.Serialization;
 using System.ServiceModel;
 using System.Text;
 namespace WASHostedWCFService
     public interface IMyService
         int Add(int num1, int num2);
 //Below is the interface implement code: 
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Runtime.Serialization;
 using System.ServiceModel;
 using System.Text;
 namespace WASHostedWCFService
     public class MyService : IMyService
         public int Add(int num1, int num2)
             return num1 + num2;

Here is my web.config code

 <?xml version="1.0"?>
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
     <compilation debug="true" targetFramework="4.5.1" />
     <httpRuntime targetFramework="4.5.1"/>
       <service name="WASHostedWCFService.MyService" behaviorConfiguration="ServiceBehavior">
         <!-- Service Endpoints -->
         <endpoint binding="netTcpBinding" contract="WASHostedWCFService.IMyService" >
         <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
         <behavior name="ServiceBehavior">
           <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
           <serviceMetadata httpGetEnabled="true" />
           <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
           <serviceDebug includeExceptionDetailInFaults="false"/>
     <modules runAllManagedModulesForAllRequests="true"/>
         To browse web app root directory during debugging, set the value below to true.
         Set to false before deployment to avoid disclosing web app folder information.
     <directoryBrowse enabled="true"/>

To enable different binding to the hosted service, Go to the Start menu -> Programs ->Accessories. Right click on the "Command Prompt" item, and select "Run as administrator" from the context menu.

Execute the following command

appcmd set app "Default Web Site/WASHostedWCFService" /enabledProtocols:http,net.tcp

Output will be shown below


Now the service is ready to use.

Now we will be creating the client application as shown below and add the reference 'System.ServiceModel', this is the core dll for WCF.


Next we can create the proxy class using service utility and add the proxy class to the client application. Creat the proxy class using Visual Studio Command prompt and execute the command

svcutil.exe net.tcp://localhost/WASHostedWCFService/MyService.svc


Add the generated proxy class and content of output.config file in App.config to WASHostedWCFClient application.

Within the Program.cs add the following code:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 namespace WASHostedWCFClient
     class Program
         static void Main(string[] args)
             MyServiceClient objMyServiceClient = new MyServiceClient();
             Console.WriteLine(objMyServiceClient.Add(2, 3).ToString());

Now build and run the client application, it will call the service and return the summation as 5.


Happy Coding

Tarun Kumar Chatterjee

blog comments powered by Disqus

SharePoint Pals

SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile


Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community

SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation