Windows Communication Foundation hosting methods for distributed industrial applications.
Gastermann, Bernd ; Stopper, Markus
1. INTRODUCTION
Nowadays, heterogeneous software solutions are applied in many
automated businesses. Although these solutions cover their destined
application area, they often also harbour the risk of being incompatible
with software systems from other operational levels. While progress
continues and new demands need to be satisfied, new services for staff
and customers have to be provided continuously, which in turn steadily
increases the complexity of the whole system. Because of that, companies
often take advantage of building a service-oriented architecture (SOA).
Most distributed systems base upon the design principles of SOA. A
service-oriented architecture consists of several independent--and
therefore loosely-coupled --services. Due to standards which apply to
all manufacturers, these services are completely interoperable. Usually,
a service is a self-contained business function and its functionality is
exposed via a structured messaging scheme. From a technology point of
view SOA is nothing new but its advantages are definitely
standardisation, reusability of single components or services and easy
exchange--and extensibility due to their independence (Klein, 2007).
2. WINDOWS COMMUNICATION FOUNDATION
In order to implement a service-oriented architecture many
approaches and technologies can be used. Windows Communication
Foundation (WCF) is one of them. WCF is a software development kit which
is explicitly devoted to communication between software systems. Hence,
it can be used to develop services as well as corresponding applications
for use in a service-oriented architecture. WCF is part of
Microsoft's .NET Framework 3.0 and higher. It allows consistent
communication and is well suited for various scenarios in which
applications need to exchange data with other services. WCF unifies some
of the best features of several other communication technologies and
models like Web Services, Remoting or Microsoft Message Queue (MSMQ).
All these technologies are encapsulated in order to form a common
programming model and provide unitary access. Even though it offers a
broad spectrum of communication mechanisms, it can easily be extended to
include custom functionality (McMurtry et al., 2007). One advantage of
WCF is its support for open industry standards (WS-*) and it is
therefore perfectly suited for communication between heterogeneous
systems. These standards allow client applications to consume services
running on different platforms. At the core of this interoperability
lies XML. Message exchange works in particular on basis of SOAP and
WSDL. Due to message-based communication WCF is well suited for use in a
service-oriented architecture. In consideration of all these aspects,
three design goals which took an important part during the development
of WCF can be identified (Peiris & Mulder, 2007):
* Unification of established technologies
* Interoperability between platforms
* Service-oriented development
3. WCF BASE ARCHITECTURE ASPECTS
Several key components have to be considered if WCF is used for
communication with services: Endpoints including their ABCs to describe
a service as well as a hosting environment in which the service
ultimately runs. An endpoint acts as a service-access-point from the
outside. Each endpoint needs to be described by the ABC concept (Klein,
2007). ABC stands for Address, Binding and Contract. The path to an
endpoint is specified by an address. Transport and communication scheme
to that endpoint is characterised by the binding. It defines among
others, how messages between client and service are exchanged, which
transport protocol should be used and which security mechanisms have to
be applied. Through contracts all operations offered on a specific
endpoint are disclosed to the client. Beyond that contracts also define
the internal message structure and layout. Through contracts platform
independence is maintained. Definition of endpoints and ABCs has to be
done during development. However, in order to run a service it has to be
hosted in an appropriate environment (Lowy, 2008). This paper deals with
the question which service host is best for use in an industrial
application environment.
4. WCF HOSTING TECHNIQUES
In order to access a WCF service it needs to be hosted in an
appropriate environment. Such an environment consists of a process in
which the service itself runs. The only requirement for the host is to
support .NET application domains. For this reason the following four
common hosting methods are to be considered: Managed .NET applications,
Windows Services, Internet Information Services (IIS) and Windows
Activation Services (WAS). Hosting in any custom application type is
possible as long as it supports application domains. Each of these types
can be classified to one of two categories: Self-Hosted and Hosted.
A type of host the developer has to write on its own is considered
a self-hosted environment. As it has to be written completely by the
developer himself these hosts do not contain any manageability features
by default. However, this approach offers full control over the hosted
service and its life cycle.
Hosted environments are--contrary to self-hosted
environments--prefabricated hosts that do not need to be developed and
already contain several management features. As these pre-existing hosts
handle the service in their own way, the developer only has limited
influence on the service's life cycle while hosted in this type of
host (Peiris & Mulder, 2007).
Each of these hosting environments has certain advantages and
disadvantages. Thus, they are not suitable for every application area.
In a service-oriented architecture the right host is essential for
service robustness. When choosing a hosting environment, it is important
to identify the type of service and its availability demands. As the
service implementation in WCF is platform agnostic it can easily be
ported from one host to another. The following topics have to be
considered when selecting a host (Microsoft, 2009):
* Availability
* Reliability
* Manageability
* Versioning
* Deployment
* State
Over the next chapters each of WCF's standard hosting
environments is introduced.
4.1 Managed Applications
Managed .NET applications are categorised as self-hosted
environment as they have to be written by the developer. That also
includes graphical applications like Windows Forms and WPF applications
but also console applications. This type of host is easy to develop with
only a few lines of code, effortless to install and poses almost no
demands to the system it is running on--except for the .NET Framework
itself. Unlike other hosting methods this type is ideal for testing,
debugging and demonstrating. It can also be used for user interaction
and service control if necessary. As this is a completely self-made host
it does not contain any features for high availability, easy
manageability, robustness, recoverability, versioning and deployment
scenarios as IIS does for example. Therefore, it is the developer's
responsibility to write the code for starting and stopping the service.
This implies that the service needs to be activated manually. The
developer thus gains full control over the service's life cycle.
Managed applications usually run under limited user accounts and have to
be started and stopped explicitly. A service hosted this way is only
available when the host runs. However, managed applications support all
kinds of transport protocols available for WCF (Peiris & Mulder,
2007).
4.2 Windows Services
A Windows Service is maintained by the operating systems Service
Control Manager (SCM). Although the developer has to write the Windows
Service which in turn hosts the WCF service, this Windows Service itself
is hosted and maintained by the SCM. This allows the developer to have
full control over the life time of the WCF service as it has to be
explicitly opened and closed from code. Windows Services are easy to
develop but do not provide any graphical user interface. This type of
host is ideal for long-running services as they are continuously
monitored by the SCM of Windows. It offers limited support for features
like auto-start on system boot and recovery in case of an error. This
makes the service available as soon as the computer starts, regardless
of whether a user is logged in or not. Furthermore, it allows each
service to have its own account and security permission. Windows
Services are easy to maintain by administrators as they often do already
have knowledge about how to configure them. Nevertheless, installation
software is necessary to install a service on the system (Peiris &
Mulder, 2007).
4.3 Internet Information Services Hosting
WCF services can also be hosted using Microsoft's Internet
Information Services (IIS) version 5.1 or higher. As IIS is primarily
used as web server it only supports HTTP as transport protocol for WCF
services. However, IIS 7.0 already includes Windows Activation Services
(WAS) which enables support for all WCF protocols. IIS is categorised as
a hosted environment and therefore controls each WCF service's
instantiation. This can only be influenced by a custom Factory written
by the developer. The huge advantage of IIS lies in its many management
features like process health monitoring, idle shutdown, process
recycling, resource throttling and logging. It offers the same
functionality for WCF services as for ASP .NET applications. Since IIS
is a complete, stable environment no additional development effort is
necessary. Everything is done solely by configuration. Compared to
managed applications and Windows Services IIS uses automatic,
message-based activation. It is important to know that many of its
features as well as its activation mechanism can also cause unexpected
behaviour compared to other hosting methods (Peiris & Mulder, 2007).
4.4 Windows Activation Services Hosting
Windows Activation Services (WAS) features all advantages of IIS.
Although it is part of IIS 7.0 it can be installed, configured and
operated independently. WAS also uses message-based activation for
services but contrary to IIS, WAS supports all available transport
protocols of WCF, including HTTP, TCP, MSMQ and Pipe. For that purpose
it installs listener adapters for each protocol. WAS is only available
on Windows Vista and Windows Server 2008 or higher (Microsoft, 2009).
5. CONCLUSION
Hosting distributed applications in a company is subject to certain
requirements. These applications have to be hosted primarily in a
stable, highly available, maintainable and resource-effective
environment. Usually it is not necessary for a service to include a
graphical user interface. Under these circumstances managed applications
are definitely not well suited because they offer neither management nor
high availability features by default. Given that, Windows Services and
IIS are the better choice. Nevertheless, this paper's
recommendation for hosting distributed applications in an industrial
environment is WAS. From all discussed hosting methods WAS is the one
which delivers most benefits. It satisfies all previously mentioned
hosting requirements for distributed applications. Most companies
already use web servers and have web server administrators at their
disposal. Regarding these aspects WAS is a good choice that could be
implemented even without staff-training as its configuration is similar
to IIS.
6. REFERENCES
Klein, S. (2007). Professional WCF Programming, Wiley Publ. Inc.,
ISBN: 978-0-470-08984-2, Indianapolis, USA
Lowy, J. (2008). Programming WCF Services, 2nd Edition,
O'Reilley Media Inc., ISBN: 978-0-596-52130-1, Sebastopol, USA
McMurtry, C., Mercuri, M., Watling, N. & Winkler, M. (2007).
Windows Communication Foundation Unleashed, Sams Publishing, ISBN:
978-0-672-32948-7, Indianapolis, USA
Microsoft (2009). Hosting in Windows Process Activation Service,
Available from: http://msdn.microsoft.com/enus/library/ms734677.aspx,
Accessed: 2009-10-20
Peiris, C. & Mulder, D. (2007). Pro WCF--Practical Microsoft
SOA Implementation, Apress Inc., ISBN: 978-1-59059-7026, Berkley, USA