Service Oriented Architecture and WCF 【转】
http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF
Introduction
This article will not talk about how to create and host a WCF service rather we stress on importance of SOA and WCF.
If
you are a advanced WCF developer then article is not for you, if you
are one who is trying to learn WCF then article is not for you, this is
for them who is completely new to WCF and trying to understand why WCF
is there.
Index
- Evolution of SOA
- Architecture Terminologies
- What is SOA?
- Characteristics of SOA
- WCF and Web services
- Conclusion
Evolution of SOA

Evolution is the nature’s law. Just like Human beings
who evolved from Primate to Modern age Humans just to adapt the moving
environment and competitions, Programing style or we can say technique
also evolved to overcome the challenges in the changing programming
world.
Procedural Programming
Initially programmers used this approach for developing applications where Functions were everything.
In this approach Functionalities will be
encapsulated inside one or more functions, which can call each other,
pass some parameters and get some return value. Here one of the
functions will be made as entry point (like in C programming we had main
method).
Why it need to be evolved.
The biggest challenges with this approach were,
- How to reuse the same code?
- Difficulties in code Management.
Object oriented Programming
To overcome the problems in the Procedural
programming, object oriented era comes into the picture where people
start talking in terms of objects and classes.
Everything is treated and considered as real world objects created from
the blue print that is class.
Lots of Object oriented principles like Abstraction,
Encapsulation, Inheritance, polymorphism and solid has been introduced
are introduced in this era.
Why it need to be evolved.
OOP increased the reusability and thus improved the
code management. But one thing which was not addressed here was how two
or more applications will communicate each other,
especially when they have been written using different
languages or technologies.
For instance inventory module which is written using Java
will not be able to call function inside classes of accounting module
written in .NET.
Service oriented Programming
We have progressed from functions, to objects and now to services.
In SOA functions and tasks are created as loosely connected independent services communicating via messages.
Service provider publishes the service via standard interfaces in a publicly accessible directory called
Service Repository and Service consumer make a service request and in response gets the Service Response.

Architecture Terminologies
Before we go in depth and talk about SOA (Service
oriented architecture), it’s must to understand some terminologies
related to architecture.
Patterns
In simple words Pattern is a solution to a problem in a context.
Architectural Style
When we say architectural style, it’s a very high
level thing, it’s a concept. It’s up to us how we take this and
implement. For example REST is an architectural style which tells us how
we can use standard web features in effective way. It’s not standard or
specification, in a style which we can understand and design web
services in that style. In my perspective n-Tier is also an
architectural style, it says divide your systems into different tiers
but middle tier may be anything, and developer can make it a simple
class library or a WCF service. In face the value of ‘n’ is also not
sure.
Architectural Patterns
Architectural Pattern is something which solves our
problem at sub system level or in short module level. It deals with the
problem related to architecture of a project. We make Class libraries,
Components, Web services to solve the problem. For example - In MVC we
break the application into Model, View and Controller. Here we know how
View interacts with model and so on.
Design Patterns
Design pattern talk about problems at class or function level.
What is SOA?
SOA or Service oriented architecture is an
architecture style for building business applications by means of
services. Application comprises collection of services which communicate
through messages.
Service
- Services are logical encapsulation of self-contained business functionality
- Every Service encapsulates one action such as Register User, Send Email etc.
Messages
Services communicate with each other using messages.
Messages are standard formats which everyone (every service) can read
and understand.
Characteristics of SOA
- In SOA, Services should be independent of other services.
Altering a service should not affect calling service. - Services should be self-contained.
When we talk about a RegisterCusomer service it
means, service will do all the necessary work for us, we are not
required to care about anything. - Services should be able to define themselves.
Services should be able to answer a question
what is does? It should be able to tell client what all operations it
does, what all data types it uses and what kind of responses it will
return. - Services should be published into a location (directory) where anyone can search for it.
- As I said, SOA comprises of collection services which communicate via standard Messages.
Standard messages make them platform independent.
(Here standard doesn’t mean standard across
Microsoft it means across all programming languages and technologies.) - Services should be able to communicate with each other asynchronously.
- Services should support reliable messaging.
Means there should be a guarantee that request
will be reached to correct destination and correct response will be
obtained. - Services should support secure communication.
WCF and Web services
WCF is a Microsoft framework for building Service-Oriented applications.
Comparing Web services with WCF will not be a good
idea. Can you compare yourself with yourself in past(let's say two year
before)? Obviously in two year you might have learned new things,
improved somewhat,right? WCF and Web service are related to each other
in same manner. WCF has evolved from Web services and so WCF can do all
which a web services is capable of, plus can do some more.
Features of WCF
- WCF hosting - If we are working
with web services then only option we are having is hosting it inside
web server such as IIS using http or wshttp protocols. But WCF supports
four types of hosting- IIS
- WAS (Windows process activation services)
- Self-hosting
- Windows services
Read more about WCF hosting at
http://msdn.microsoft.com/en-us/library/bb332338.aspx - Message transmission - Messages
can be transmitted between clients and service via various transport
protocols and encodings such as SOAP using http and binary data using
TCP. - Serialization - Web services uses XmlSerializer for transferring data between service calls whereas WCF supports multiple serializers
- DataContractSerializer(faster and supports versioning)
- NetDataContractSerializer(when it required to include CLR type information in the serialized XML)
- XmlSerializes(mostly to support backward compatibility).
- Multiple technologies at one place - WCF unites following four technologies
- .NET remoting
- MSMQ
- Web Services
- COM+
- Message Contract - In Web
services customizing the headers of the SOAP message was a tedious task.
For that we were supposed to derive a class from SoapHeader and then
SoapHeaderAttribute is used to indicate the presence of the header.
But with WCF we can make it easily with the help
of simple attributes like MessageContractAttribute,
MessageHeaderAttribute, and MessageBodyMemberAttribute. - Multiple Message Patterns - WCF supports three message patterns that describe how client and service pass messages
- Request-Reply Pattern – Client sends message to service and waits for reply.
- One-Way Message Pattern – Client sends message to service but service does not reply message to client.
- Duplex pattern – Both client and the
service can initiate communication. The client calls a method of the
service. The service can then use a client callback to call a method in
the client.
- Security - In WCF security can be implemented with the help of well-known standards such as SSL.
- Reliable - WCF supports reliable messages with the help of Queues and reliable sessions.
- REST - WCF can be extended to
support plain xml data that is not wrapped in a soap envelope, xml
formats such as ATOM and non xml standard such as JSON. - WCF Transaction - - WCF
supports to create distributed transactions for your service
application. Transaction is a collection of logical operations which
need to be run as a single logical unit.
(Either all operations will successfully execute
and completes or in case any of them fail others will rollback). - WCF instancing - In WCF we can
control the way WCF service objects are instantiated in the WCF server.
WCF Framework comes up with following instancing models- Per Call - A new instance will be created for every client request.
- Per session - A new instance is created for each new client session and maintained for the lifetime of that session.
- Single - A single instance handles all client requests for the lifetime of the application.
- WCF Concurrency - With WCF
Concurrency features we can control how service instances can serve
multiple requests at the same time. We have three choices- Single – Only one request will be served at a time.
- Multiple - Multiple requests can be handled by the WCF service object at any given moment of time.
- Reentrant - A single request thread has
access to the WCF service object, but the thread can exit the WCF
service to call another WCF service or can also call a WCF client through
callback and reenter without deadlock.
What is ABC in WCF
We had gone through the feature of WCF and
understood why its termed as advanced version of web services. Now it’s
time to answer a very basic question related to WCF i.e., what is ABC of
WCF?
When we say WCF, we came across end points. Service
endpoint can be a part of continuously hosted service hosted in IIS or
service hosted in an application.
ABC or Address, Binding and Contract are the three elements which constitutes and Service Endpoint.
- Address - Where Service is residing (URL of the service.)
- Binding – How to talk to the service?
- Contract – What can the service do for me?
Example – basicHttpBinding, wsHttpBinding, webHttpBinding etc.
Conclusion
We have understood
- What is Service oriented architecture?
- Why SOA required?
- What are the characteristics of SOA?
- How WCF can be differentiated from Web service?
- What are the characteristics of WCF?
- What is mean by ABC of WCF?
Service Oriented Architecture and WCF 【转】的更多相关文章
- Service Oriented Architecture
What is Service Oriented Architecture (SOA)? There have been so many interpretations of this through ...
- SOA (面向服务的架构)-Service Oriented Architecture
SOA (面向服务的架构) 编辑 面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立 ...
- service oriented architecture 构造分布式计算的应用程序的方法 面向服务的架构 分解技术
zh.wikipedia.org/wiki/面向服务的架构 [程序功能做为服务] 面向服务的体系结构(英语:service-oriented architecture)是构造分布式計算的应用程序的方法 ...
- The service ‘xxx’ configured for WCF is not registered with the Autofac container
最近在使用autofac.wcf时,报如下异常: Exception Details: System.InvalidOperationException: The service 'xxx' conf ...
- 重温WCF之构建一个简单的WCF(一)(2)通过Windows Service寄宿服务和WCF中实现操作重载
参考地址:http://www.cnblogs.com/zhili/p/4039111.html 一.如何在Windows Services中寄宿WCF服务 第一步:创建Windows 服务项目,具体 ...
- Web Service \restful web services\WCF Service\ServiceStack
http://www.cnblogs.com/jfzhu/p/4025448.html http://www.cnblogs.com/jfzhu/p/4022139.html#3043243
- SOA相关资料整理分享
昨@幸福框架同学问能否推荐SOA一些资,.想想之前看过不少资料文档,就整理分享下,有需要的可以参考下. 文章链接 理解面向服务的体系结构中企业服务总线场景和解决方案,第 1 部分 SOA 和 web ...
- SOA一些资料
SOA相关资料整理分享 2015-03-26 16:16 by 蘑菇先生, 693 阅读, 9 评论, 收藏, 编辑 昨@幸福框架同学问能否推荐SOA一些资料.想想之前看过不少资料文档,就整理分享下. ...
- WCF Windows Service Using TopShelf and ServiceModelEx z
http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are ...
随机推荐
- javascript 基础2第12节
1. <html> <head> <title>javascript基础</title> </head> <body> 1.Nu ...
- SGU 239.Minesweeper
题意: 如图,一列未知的区域长度为n(≤1000),给出第二列的数字,求区域中雷的排列有多少种. Solution: 搜索.这题看上去1000的范围很大,实际上加上合理的剪枝,状态数会变得非常非常少. ...
- Socket 死连接详解
Socket 死连接详解 当使用 Socket 进行通信时,由于各种不同的因素,都有可能导致死连接停留在服务器端,假如服务端需要处理的连接较多,就有可能造成服务器资源严重浪费,对此,本文将阐述其原理以 ...
- 从追MM谈Java的23种设计模式
从追MM谈Java的23种设计模式 1.FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯 德基,只管向服务员说“来四个鸡 ...
- C程序的构成及动态内存分配
对一个程序,通常的理解就是,源码编译成机器代码,然后通过机器解释运行.不过是怎样编译成机器代码,和怎样运行的,无疑是个值得探讨的问题.怎样编译成机器代码,过程就是源码的编译.链接,编译器做了这些事.而 ...
- yaffs2文件系统
1 .yaffs2源码目录文件复制到需要移植的linux内核目录fs/下 同时替换掉源码文件中的Makefile文件跟Kconfig文件. 2.在内核中添加对yaffs2的支持. 3.在make me ...
- 文件操作 系统备份和还原,压缩,解压 tar dump/restore
基本操作命令: ls -a 显示指定目录下的目录和文件,包括隐藏的文件和目录 ls -l 将文件和目录详细列出来,包括文件状态,权限,拥有者,文件名,文件大小等 改变工作目录命令 cd cd .. 进 ...
- Android Activity 生命周期详解
学习android开发这么久对于activity的生命周期还没有仔细思考过,所以,我大致的把这些东西整理一下,希望通过这使自己理解的更透彻点吧! 首先看一下Activity生命周期图和它的的四个阶段 ...
- PHP对URL设置
一.URL规则 1.默认是区分大小写的 2.如果我们不想区分大小写可以改配置文件 'URL_CASE_INSENSITIVE'=>true, //url不区分 ...
- C#中的反射 Assembly.Load() Assembly.LoadFrom()
一些关于C#反射的知识,估计也就最多达到使用API的程度,至于要深入了解,以现在的水平估计很难做到,所以下面此篇文章,以作为一个阶段的总结. 对于反射的总结,我想从以下几个方面展开,首先是反射程序集, ...