Thursday, April 14, 2011

How to configure Windows Server 2008 to host WCF services in IIS 7/WAS

Configuring Windows 2008 server for hosting WCF services in IIS7.0 and WAS


This document is focused on hosting a WCF service on Windows 2008 service Windows Activation Server (WAS). This service is utilizing tcp net as binding protocol.


Below are the steps:
  • Enable Network Discovery
  • Create a folder for your service code in root (c:\ MyService)
  • Add Roles and features:
    1. Add Web Service Role (IIS) to server, it will require to add WAS feature. (Figure 1)
    2. Add Application Server Role, this will require to install WAS feature. (Figure 2)
     Figure 1)  Adding Application/Web Server Roles 
     Figure 2) Adding Application Server Role
    Figure 3) Adding WAS Application Server Roles
    Figure 4) Choosing Authentication Certificate for SSL Encryption

  • Select all items under Security
  • Go to Features Expand .NET framework 4.0 Features, check WCF Activation box.(done in previous section)
  • Add Network Load Balancing Feature (See Figure 5) There will be another posting to cover setting up NLB.


Figure 5) NLB installation

    1. Register .NET Framework (use Framework64 folder if you are on a  64 bit machine)
      1. "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\aspnet_regiis" –i –enable
    2. Register WCF   (use Framework64 folder if you are on a  64 bit machine)
      1.  "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\ServiceModelReg.exe" -r


    1. Create Application/virtual directory
    2. Set additional virtual directory properties
    3. Set security:
    4. Add your designated service account myServiceAccount  to below User Groups
      1. Performance Log Users
      2. IIS_IUSRS



       Option 3: Enable a port range in advance. Start the Windows Firewall Control Panel applet
 and enable ports 80, 443, 8000-8003 and 9000, which are used by the samples. You can find more detailed instructions in the following procedure. This option is less secure than the others because it allows any program to use   these ports, not just the samples
    1. Chose option 3 from above link.       
    2. Create new Inbound, Outbound rules (named WCF-WF-TCP-Ports)
  • Edit site bindings: Run below commands

    Command1: %windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']


                 Command2:%windir%\system32\inetsrv\appcmd.exe set app "Default Web      Site/yourServiceName" /enabledProtocols:http,net.tcp

Use a Meta Data Explorer to explore addresses:
Example client URI for MyService:
Client URI: net.tcp://servername.domain/MyService/MyService.svc
Meta Data URI: net.tcp://localhost/MyService/MyService.svc/mex

Related Links:
  1. http://msdn.microsoft.com/en-us/library/ms752218.aspx
  2. http://msdn.microsoft.com/en-us/library/ms751530.aspx
  3. http://msdn.microsoft.com/en-us/library/ms733768.aspx
  4. http://msdn.microsoft.com/en-us/library/ms751432.aspx
  5. http://msdn.microsoft.com/en-us/library/ms751527.aspx