How to configure WAS for TCP endpoints in IIS March 5, 2012Posted by fofo in C#, Visual Studio 2008, Visual Studio 2010, WCF, WCF Service.
Tags: IIS, WAS
In this post I would like to show you how to activate Windows Activation Services or WAS for TCP based activation.What this means is that it is possible to host WCF Services in IIS and expose TCP endpoints. Recently I have posted 3 posts on WCF hosting options. You can find them here , here and here.
1) We need to create our WCF Service first.We will use the exact same example we used when we hosted a WCF Service in IIS (full version) .Click here to see this post. You have to follow all the steps as they were described in that post. After you finish all the steps in that post you will have successfully hosted a WCF Service in IIS.
2) I will show you how to install WAS in your machine.Go to the Control Panel–> Program and Features and select Turn Windows features on or off.Then you need to select some options/components to install. Have a look at the picture below to see what those options are
3) Now I need to run some commands to enable TCP and other protocols on the Default Web Site. I will do that using the appcmd command.Open a Visual Studio 2010 command prompt as an administrator and browse to this folder C:\Windows\System32\inetsrv. Then type appcmd.exe set site “Default Web Site” -+bindings.[protocol=’net.tcp’,bindingInformation=’808:*’] and hit Enter.Then in the new command prompt type appcmd.exe set site “Default Web Site” -+bindings.[protocol=’net.pipe’,bindingInformation=’*’] and hit Enter. Then in the new command prompt type appcmd.exe set site “Default Web Site” -+bindings.[protocol=’net.msmq’,bindingInformation=’localhost’]
Hopefully these commands will execute successfully and these protocols are enabled on the Default Web Site.Now we need to enable those protocols on the CalculatorServiceSite website that hosts our WCF service.In the same Visual Studio 2010 command prompt window type
appcmd.exe set app “Default Web Site/CalculatorServiceSite“ /enabledProtocols:http,net.pipe,net.tcp,net.msmq
Now we have enabled those protocols for our site.Now we are ready to expose endpoints over alternate protocols e.g TCP,MSMQ. In this way we can have our WCF Service hosted in IIS and still consume it over the network with clients that support/understand the TCP/IP protocol.
Hope it helps!!!