Sie sind auf Seite 1von 4

2009 International Conference on Web Information Systems and Mining

A Service-Oriented Distributed Framework—WCF


Wei Zhang Guixue Cheng
College of Computer and Information Engineering College of Computer and Information Engineering
Shanghai University of Electric Power Shanghai University of Electric Power
Shanghai, China Shanghai, China
zhangweismile@163.com richie_cc@126.com

Abstract—WCF(Windows Communication Foundation) ,one of base class functionality. But it was language-based reuse and
Microsoft's revolutionary products, represents a new step in didn’t facilitate the dynamic evolution of software at
distributed programming. In this paper, after the concepts of runtime. Later, component-orientation overcame the
WCF are introduced, its pillars(SOA, interoperability and challenges. It provided interchangeable, interoperable binary
integration, unification) are discussed and layered architecture
components, so possibility for cross-language
is explored, then the difference between WCF and Web
services is summarized . Finally, current state of popular interoperability, and forced the developer to think about the
technologies is given, and the future importance of WCF is external facing interface of the application, which enabled us
pointed out. to build systems that dynamically load and bind to new
functionality at runtime[2]. But tight coupling is its
WCF , SOA, interoperability, integration, unification, Web important limitation. Distributed applications built with it
services, distributed development need a common platform and operating system, and have to
version simultaneously. Such characteristics make it
I. INTRODUCTION unsuitable for a variety of network environment. Now,
In recent years, distributed system has made considerable service-orientation offers a tremendous leap forward. It is a
progress, with the increasing popularity and scale of collection of well-defined services, where each individual
computer application. Meanwhile, more demands are put service can be modified independently of other services to fit
forward to it, such as openness, security, scalability, the ever-evolving business[3].The communication is
concurrency, transparency and so on. Especially, the reflected in the publishing and consumption of services by
applications need to work together, need to exchange since the message-based approach based on open standards.
they are seldom totally independent. And generally they run Overall, SOA adheres to the following four tenets of service-
on different hardware, different operating systems, and orientation, which help ensure that the services are extremely
different platforms. After all, each hardware type, operating flexible and resilient to change, thereby reducing long-term
system, and platform can have its own type system, memory maintenance costs. And WCF takes SOA concepts of
management scheme, transports, and protocols. Recognizing message passing, schema, contract, and policy, and
the need to bridge the gap between various environments, implicitly applies it to all of the services. As such, WCF
Microsoft developed what is known as the Windows provides the SOA programming model.
Communication Foundation (WCF).And regards it as one of Tenet 1:Boundaries are explicit. It specifies that the
Microsoft's revolutionary products. messages must be able to cross explicit and formal
It says WCF which was code-named Indigo is a unified boundaries regardless of what is behind those boundaries,
programming model for building service-oriented which means a service can be deployed anywhere and be
applications. It enables developers to build secure, reliable, easily and freely accessed by other services, rather than
considering the environment or development language of the
transacted solutions that integrate across platforms and
other services[4].With WCF, the attribute-based programming
interoperate with existing investments[1].Because of the
enables developers to explicitly define external service
exciting features, WCF has aroused widespread concern.
contracts. Without explicitly defining these, no functionality
II. THREE PILLARS OF WCF will be exposed publicly.
Tenet 2: Services are autonomous. It states that each
A. Addressing the SOA (Service-Oriented Architecture) service must be managed and versioned differently so as to
needs not affect other services in the process, which supports the
inevitable evolution of the service’s implementation over
For years, software development has focused on how to time. It is obvious since the underlying implementation
best reuse the code that we write. Object-oriented details are hidden from the consumer, any change to the
development put forward the idea of building reusable implementation will not affect the service as long as the
classes from which could be inherited in order to reuse the contract does not change[3].

978-0-7695-3817-4/09 $26.00 © 2009 IEEE 302


DOI 10.1109/WISM.2009.69
Tenet 3: Services share schema and contract. Services Enhancements (WSE) ,MSMQ,.NET Remoting and so
pass schemas and contract rather than classes and types. And on. Each programming model has a different set of APIs,
the clients use them to generate their own code to call the different feature sets, and a different core set of scenarios:
service. This allows for a loosely coupled system where .NET Remoting — an efficient means of communication
neither service requires knowledge of each others’ internal between .NET Framework applications by exposing the CLR
workings in order to exchange data—they only need the type system remotely and providing location transparency
published schemas and contracts. for objects, if all nodes in a distributed application are .NET
Tenet 4: Service compatibility is determined based on Framework applications.
policy. This is how services interact. Services look at each MSMQ—a set of objects to perform queue messaging in
others’ policy, looking for similarities so that they can start Windows, which is a best choice for an application required
communicating. With WCF, the services communicate guaranteed message delivery and durability.
through dynamically negotiated communications channels ASMX — a way to expose the functionality of remote
that support the necessary semantics (security, reliability, components via standard web protocols and provide
etc). Service policy statements create automatically based on interoperability with web services running on non-Microsoft
configuration, class attributes, and method signatures. Client platforms.
channels automatically configured via retrieved service WSE — a supported extension to the .NET Framework
policy. that provides end-to-end standards-based security for Web
services.
B. Interoperability and Integration
Enterprise Services —an offering of managed APIs to
In fact, through the above discussion, interoperability and COM+ which provides component-based programming for
integration issues are a matter of course, however, due to its doing enterprise critical functionality such as transactions.
importance, a separate list for discussion. And so on, not detailed here one by one. So it is very
WCF interoperability and integration fall into two key difficult to pick the right technology for the job due to their
scenarios. For interoperability, the ability to communicate diversity and isolation from one another as mentioned above,
with applications running on other platforms provides the and further complicated by the fact that several of these
flexibility you need when working in a heterogeneous technologies overlap in the features they provide (most
environment. And for integration, the ability to communicate notably in the areas of transactions and security)[6].
with existing applications protects the investments and Furthermore, combination is required in practical
provides an optional, incremental upgrade path to WCF. applications. For example, if the designers want to use the
How to achieve it with WCF? Thinking of the well- ASMX, as well as want to provide direct reliable messaging
known Internet, there exist so diverse network styles. But the guarantees. Or if want to use .NET Remoting for it's rich
Internet could connect them together to communicate as we extensibility model, as well as want a ES-style transaction to
know. The key is TCP/IP protocol. Similarly, with WCF, the flow. There is no good option to accomplish it, before WCF.
key is message-based approach based on open standards, as WCF fuses these different distributed technologies and
mentioned above. As a result of being based on open unifies them under one programming model, as shown in
standards and using messages that are generic and not Table I[5].
representative of any specific platform and programming
language, it’s easy to achieve a high degree of loose coupling TABLE I. WCF FEATURE COMPARISON
and interoperability across platforms and .Net
technologies[3].SOA focuses on the message rather than the Feature WSE ASMX COM+ MSMQ WCF
Remoting
implementation, platform, or runtime of the service itself. WS-* support √ √ √
So what is the “open standards”? It is WS-* protocol, BasicWebServiceint
which is a family of specifications that define universal eroperability √ √ √
message structures and messaging choreographies. This .NET-to-.NET
family of specifications includes WS-Addressing, WS- √ √
communication
Security, WS-Trust, WS-SecureConversation, WS- Distributed
√ √ √
Federation, WS-ReliableMessaging, WS- transactions
AtomicTransaction, WS-Coordination, WS- Queued messaging √ √
MetadataExchange, WS-Policy, and WS-PolicyAttachment. (note:“√” figures the item supports the corresponding feature )

They use message structures based on XML and SOAP. And


they are a de facto standard message format, providing a
vendor-agnostic way for applications to communicate In addition, WCF is designed to reduce development
reliably, securely, and in a transacted manner[5].WCF fully complexity and make developers that are already familiar
embraces SOAP and WS-*. with existing technologies such as ASP.NET,.NET remoting
and Web Services feel comfortable with the new
C. Unified programming model technology[8].Besides, it provides integration and
Until now, developers have had a plethora of technology interoperability with existing .NET technologies as
choices to choose from for building distributed applications, mentioned above.
such as ASP.NET Web Services (ASMX),Web Services

303
III. WCF ARCHITECTURE
Client Server
Casually observing WCF, it appears remarkably simple.
The services are deployed, discovered and consumed as a ServiceModel Dispatcher
Proxy
collection of endpoints, each of which is the fusion of the Layer
address, binding, and contract, known as ABC. And a service
must have at least one endpoint ,as illustrated Fig. 1[10]. …… ……

Client Server Reliability Channel Reliability


Layer
endpoint endpoint Security
Security
C B A A B C
Encoding
channels Encoding
channels
message endpoint
A B C message
Transport Transport

Figure 1. communication through the endpoint Figure 2. ServiceModel Layer and Channel Layer

An address defines where the service is, including the WCF is a layered architecture, split into two major
location of the service and the transport protocol. The layers: the ServiceModel layer and the Channel layer. And
location portion of the address indicates the name of the the real work of messaging is in the Channel layer. A
target machine, site, or network; a communication port, pipe, channel carries out messaging like a pipe. A message is sent
or queue; and an optional specific path, or URI (Universal form the sender to the receiver like through the channel
Resource Identifier).The transport protocol includes “pipe”. As linking a number of these pipes together, with
HTTP,TCP,MSMQ and so on. each pipe has it own specific function, a channel stack forms.
A binding defines how to communicate with the service. Each channel carries out one aspect of the messaging
The communication relates to multiple aspects, such as functionality in an application. For example, if a WCF
message encodings, transport protocols, security options, application requires security, reliability and transactional
communication patterns and so on. Bindings group together capability, one channel will be used for security, another for
sets of such communication aspects suitably to make reliability, and another for transactional capability. So
developers easily deal with communication function. WCF according to the application’s requirement, channels could be
provides built-in bindings that fill common needs such as stacked in various ways. In essence, the binding, mentioned
Basicbinding, TCPbinding, IPC binding and so on .Besides, earlier, controls the channel stack. A specific binding means
developers could customize it. a specific channels. So there is no concrete, one-size-fits-all
A contract specifies what operations the service can do. channel type definition as there is no concrete binding. Fig.2
WCF defines four contracts, including service contract just illustrates the composition of a typical channel stack.
which describes operations the client can perform on the However, using channel stack directly is complex. So
service, data contract which describes data types passed to WCF has the ServiceModel layer, a higher-level abstraction
and from the service, fault contract which depicts the errors layer. It is the bridge between the application and the
raised by the service and how the service deals with errors, Channel layer, offering an easy-to-use API with classes,
and message contract which allows the service to interact methods, attributes, and configuration to build connected
directly with messages[9]. applications. Notice the ServiceModel layer is called the
However, taking a closer look at a WCF ,it is a complex Proxy on the sender, responsible for creating messages to
platform. This can be felt a little from Fig. 2[10]. send to the Channel layer, and the Dispatcher on the receiver,
responsible for deserializing received messages, instantiating
an object, and dispatching the deserialized message contents
to that object[10][11].
IV. COMPARISON WITH ASP.NET WEB SERVICES
In recent years, interoperability based on Web services
has caused a great deal of attention and research. And WCF
could achieve it. So what is the difference?
In terms of performance, WCF is 25%—50% faster than
ASP.NET Web services[12].Besides, from a developer’s
point, there are following differences between them[13].
Firstly, considering message representation, the header of
the SOAP message can be customized in Web services.

304
Besides, in WCF, special attributes such as Nowadays, among the variety of distributed application
MessageContractAttribute , MessageHeaderAttribute and technologies, COM+ still plays an important role in the
MessageBodyMemberAttribute are provided to depict the industrial control field, but is gradually fading out. Web
structure of the SOAP Message. services ever is considered as a panacea for integration of
Secondly, in terms of serialization, the development of cross-platform applications and get widely used, but
Web services relies on the XmlSerializer to serialize .NET constrained due to the performance bottleneck. Perhaps the
types to XML ,while the WCF uses the upgrading of hardware could provide a better help to the
DataContractAttribute and DataMemeberAttribute to problem. WCF represents a new step in distributed
accomplish it . And DataContractSerializer is better programming for developers with more features than were
performance over XMLserialization and able to explicitly possible before as previously discussed. This new
indicate which fields or properties are serialized into XML technology ,as important part of Microsoft’s strategic plan,
which XmlSerializer couldn’t realize. represents the development direction of the software
Thirdly, in regard to service description, WSDL (Web architecture design, and get applied in the distributed
Services Description Language) is generated to describe the application more and more. The popularity of the technology
service as issuing a HTTP GET Request with query WSDL, will be enhanced If Microsoft could support a convenient
and can be customized by deriving the class of tool to integrate the existing distributed interface.
ServiceDescriptionFormatExtension in Web services. In In any case, it can be expected that WCF will hold
WCF, WSDL is generated as issuing a Request with the important status in the future development of distributed
query WSDL for the .svc file and can be customized by application.
using ServiceMetadataBehavior class.
Fourthly, about client development, the command-line REFERENCES
tool WSDL.EXE is used to generate the client for service in [1] Microsoft Corporation.(2007).Windows Communication Foundation.
Web services, whereas the ServiceMetadata tool(svcutil.exe) [Online]. Available: http://msdn.microsoft.com/en-
is used in WCF. us/library/ms735119.aspx.
Fifthly, concerning exception handling, unhandled [2] Juval Lowy, Programming WCF Services, O'Reilly Media, Inc,
November 14, 2008, Appendix A.
exceptions are returned to the client as SOAP faults in Web
[3] Chris Peiris and Dennis Mulder, Pro WCF: Practical Microsoft SOA
services, whereas unhandled exceptions are returned to Implementation, Apress, January 15, 2007,pp.4.
clients for debugging according to a configuration setting in
[4] Scott Klein ,Windows professional WCF, Wiley Publishing, Inc ,
WCF. 2007,pp.7.
At last, thinking over developing service, instead of [5] Justin Smith, Inside Microsoft Windows Communication Foundation,
adding the WebService attribute to the class and WebMethod Microsoft Press, 2007, pp.4-8.
Attribute to any of the class methods in ASMX, in WCF, the [6] Andrew Troelsen, Pro VB 2008 and the .NET 3.5 Platform ,
ServiceContractAttribute is added to specify that a interface Apress,2008, pp.801-803.
defines a WCF service contract, OperationContract attribute [7] Yan Shang , Huang Zhangchan , ”WCF:New Fundament of
is used to indicate which of the methods of the interface Communication Technology Based on Windows Platform”
defines the operations of the service contract. In brief, Web Computer& Digital Engineering,Vol.36 No.4,2008.
services attribute the specific method. WCF attributes the [8] Scott Klein ,Windows professional WCF, Wiley Publishing, Inc ,
2007, pp.58.
interface, which brings about loosely coupling the host of
the service from the implementation and leads to hosting [9] Juval Lowy, Programming WCF Services, O'Reilly Media, Inc,
November 14, 2008, pp.19,.
WCF services not only in IIS but console applications,
[10] Justin Smith, Inside Microsoft Windows Communication Foundation,
Windows forms and so on, since any class that implements Microsoft Press, 2007 ,pp.89-96,.
the interface can be a service, due to programming to an [11] Chris Peiris and Dennis Pro WCF: Practical Microsoft SOA
interface. And it is flexible that how to expose the service is Implementation, Apress, January 15, 2007,pp.69,.
up to the developer’s configuration which gives the ability [12] Saurabh Gupta.(2007,Feb.)A Performance Comparison of Windows
that the code is written once but could be repurposed Communication Foundation (WCF) with Existing Distributed
according to the need. Communication Technologies .[Online]. Available:
Overall, both WCF and Web services support the http://msdn.microsoft.com/en-
us/library/bb310550.aspx#wcfperform_topic4
characteristic of interoperability. But WCF is more flexible,
powerful but complex than Web services. It requires [13] Kalyan Bandarupalli.(2008,Oct.) WCF vs ASP.NET Web services.
[Online]. Available:http://www.techbubbles.com/ wcf/wcf-vs-aspnet-
developers take more effort to master it. web-services/
[14] Keith Elder. (2008,Oct.) WCF vs ASMX WebServices. [Online].
V. SUMMARY Available:http://keithelder.net/blog/archive/2008/10/17/WCF-vs-
So far, the previous discussion is just a start about WCF. ASMX-WebServices.aspx
There is so much more to it, such as security, transaction [15] Microsoft Corporation.(2006,Mar.)Windows Communication
Foundation Architecture Overview.[Online].
,reliable session, COM+ integration, data integration issues, Available:http://msdn.microsoft.com/en-us/library/aa480210.aspx
peer-to-peer communication and so on. Although it is just [16] David Chappell.(2007,Sep.) Introducing Windows Communication
the brief and shallow study, the attractive features of WCF Foundation.[Online].Available:http://msdn.microsoft.com/zh-
are still appreciated obviously. cn/library/dd943056(en-us).aspx

305

Das könnte Ihnen auch gefallen