WAS => Windows Activation Service
WAS is a Process Activation Service that comes with Windows Vista and IIS 7. WAS was designed to support non-HTTP protocols with the help of IIS 7 whereas IIS 6 supports only HTTP protocols. If you want to use Non-HTTP Protocols like NetTcpBinding and NetMSMQBinding over IIS , WAS hosting is the only option.
WAS Hosting
The biggest limitation in the WCF architecture before IIS 7 version was no support for non-HTTP protocols over IIS. To enable the usage of a complete list of WCF-Supported protocols including non-HTTP, such as net.tcp, net.pipe, net.msmq - WAS (Windows Activation Service) is the platform to be used. WAS,Worker process or other processes will be triggered only when the request arrives. Unlike SelfHosting ,the host process should always be started up and listening for incoming requests. Once the first request comes in from the client, the listener will call WAS to activate the worker process, then the request will be passed to the application domain handler inside the worker process who handles the request and returns the response to the client. No matter whether the request is a WCF Service request, or ASP.NET Request the Job of the activation process is to enable the worker process to start when a request comes in to the server from the client . This activation process is called message-based activation. Application domain protocol handler starts WCF Service Host inside the application domain.
Figure 1.1 WAS Process
In the above snapshot, you can find that the worker process gets activated which in turn starts the WCF service once the first request comes in from the client. After that, Server will start listening any requests from client to process and response
WAS Hosting Architecture
Figure 1.2 WAS Architecture Diagram
Once WAS is activated, the worker process starts listening any requests (Figure 1.1). As each protocol listener receives the requests, WAS checks the existence of a worker process to service the request. The listener’s job is to pull requests from the application pool queue and forward to the appropriate protocol handler for processing.
- Protocol Listeners - Listeners are responsible for receiving requests. Protocol Listener provided for all the protocols like HTTP,net.tcp,named pipes
- Listener Adapter - Adapters are responsible for bridging the requests between WAS and worker process for a particular protocol.
- Protocol Handlers- Handlers are responsible for handling the channel requests through the service model for a particular protocol.
Steps to Configure WAS Hosting
Please follow the below steps to configure WAS hosting in IIS. Step 1
Figure 1.3 Windows Features ON or OFF Make sure that .NET Framework 3.5.1 features HTTP Activation and Non-HTTP Activation are checked. Go to Control Panel -> Programs-> Programs and Features (Win 7 OS)->Turn Windows Features ON or Off. Step 2 - Make sure, the following TCP services are running (Type Services.msc in the run window). - Net.TCP listener Adapter
- Net.TCP Port Sharing Service
Figure 1.4 Services Listing
Step 3 - Creating a WCF Service Library to place all the contracts and implementations.
Figure 1.5 WCF Library Creation Screen
Just select the WCF Templates on the left-hand side and select WCFServiceLibrary on the right side and name the project name as ServiceLib and press Ok
Step 4- Design your contract and implementation as per your requirements. In our example, I have named the contract as “ServiceLib” and named the implementation as “ServiceImp”
Figure 1.6 WCF Library APP.Config File
Make sure you have selected the binding “netTcpBinding”, as mentioned in the above snapshot.
Step 5- For Hosting purposes, create one more project. Select the project type as WCF Service Application. After that, delete all the .cs files in this project except .svc file as we had the contract and implementation in the separate project ServiceLib (Step 3).
Figure 1.7 WCF Service application Creation
Step 6- Change the Service tag in the SVC file content, as mentioned in the below snapshot.
Figure 1.3 SVC File Content
Make sure that the service tag has the class name where you have implemented the service operation. In this case, ServiceImp is the implementation class in the ServiceLib Project.
Step 7- Open Internet Information Services (IIS)
Figure 1.8 Adding Application in IIS
Select the Default Website and Add Application.
Figure 1.9 ADD Application Screen
Then, just update the physical path and click OK.
Step 8- Select default website and select Edit Bindings.
Figure 1.10 Edit Binding Selection
Please make sure that you have an entry for net.tcp in SiteBindings
Step 9 - Select your site and click Advanced Settings and update the enabled protocols as HTTP,net.tcp
Figure 2.1 Advanced Settings
Figure 2.2 Enabled Protocols
After that, select the .svc extension file in IIS and browse. Then, the service will start running perfectly.
Step 10- Client Configuration
Once you are able to browse the .svc file in your project/IIS, just copy that URL and add that as a Service Reference in the client project.
Figure 2.3 Service Reference Creation
After that, just create the object for that service reference and start utilizing the service methods. Please refer to the below snapshot for details
Summary
WAS Hosting is very useful when you want to use net.tcp and net.pipe protocols in IIS. WAS Hosting works only with IIS 7 version.