Service Oriented Architecture
What is Service Oriented Architecture (SOA)?
There have been so many interpretations of this throughout the years that it seems important to establish a common understanding before I discuss WCF as an SOA platform.
The Organization for the Advancement of Structured Information Standards,better known as OASIS (http://www.oasis-open.org),provides this official definition in its Reference Model for Service Oriented Architecture:
Service Oriented Architecture (SOA) is a paradigm for organizing and utilizing distributed capabilities that may be under the control of different ownership domains.
You might add to this definition by stating that SOA relies on the ability to access chunks of business functionality,potentially owned by different applications,departments,companies,or industries.
Notice that this description does not specify the mechanism through which those chunks of functionality are accessed.
In fact,the term “service” isn’t even mentioned, although it is implied.
From OOP to SOA
The road to SOA has been a progressive one—driven by the need to improve how developers build complex enterprise systems.
The principals behind enterprise system design are far-reaching: from object-oriented programming to component-oriented programming to service-orientation.
All three approaches share the common goal of encapsulation and reuse.
With object-oriented programming, classes encapsulate functionality and provide code-reuse.
To share classes between distinct applications or binaries, however, you have to copy the code, as shown in Figure 1-2.
Figure 1-2 Duplicating types between components
Component-oriented programming has many limitations,but the most obvious is tight coupling to a specific technology.
How can a Java client call a COM component?
How can a .NET assembly invoke an EJB?
It all boils down to protocols and messaging formats.
Invoking a remote component of any kind requires serializing a message and passing it across applicable process or machine boundaries (see Figure 1-3).
Figure 1-3 Shared component containing shared types
Bridge technologies and adapters exist to transform messages from one technology into another,so that when the message arrives it can be understood and processed.
The reverse happens as responses are fed back to the caller.
This approach is cumbersome,however,sometimes introducing multiple transformations between clients and components—and sometimes not even possible.
Instead of exposing components directly,components can be accessed through service boundaries to alleviate some of this pain (see Figure 1-4).
Figure 1-4 Exposing functionality through a service boundary
So,does service-orientation solve the problems inherent to component-orientedprogramming?
It depends on where you sit on the meaning of service-orientation.
Iwould definitely agree that in its purest form, service-orientation delivers a solution to these problems by introducing (via web services) the concept of contracts,policies,and interoperability.
In that respect,applications can communicate with one another’s services,as shown in Figure 1-5,without concern over the technology each employs.
Figure 1-5 Consuming interoperable services
But you could also argue that service-orientation is an approach to development that implies the encapsulation of business components,data access,
and data storage such that access is controlled through a top-level entry point.
The package is a service,accessible over whatever protocols are supported,even if it lacks interoperability.
What Is a Service?
This is an important question—and the answer varies depending on the context of the discussion.
For example,a service is a logical term to SOA,but it has physical meaning to WCF.
I’ll focus on the former in this section.
According to the high-level definition of SOA,business functionality must be distributable and accessible in some way.
The term service in this case refers to the entry point or “window” through which business functionality can be reached.
Consider the application architecture illustrated in Figure 1-6.
Figure 1-6 Directly invoking business components
The client application represents an Agency Management System that includes many chunks of business functionality such as Certificate Issuance,General Ledger,CRM,and Reporting.
In Figure 1-6,the client application coordinates access to these features by consuming business components directly.
In this case,components are not distributable in such a way that they can be location transparent, thus they are not services.
So,what constitutes a service in SOA terms?
It could be a serviced component exposed using Enterprise Services,a .NET Remoting component,an ASMX web service,or a WCF service.
Any of these technologies can be useful in exposing the business logic in such a way that the client can reach that functionality at remote locations in a distributed environment,without communicating directly with business components. Figure 1-7 illustrates the same services beneath the Agency Management System example from Figure 1-6,but this time each feature is exposed via one of the aforementioned technologies.
Serviced components are reached using DCOM over TCP,.NET Remoting components via RPC over TCP,ASMX web services via SOAP over HTTP, and WCF services via SOAP over any protocol.
RPC stand for Remote Procedure Call Protocol远程过程调用协议
Figure 1-7 Service boundaries implemented with different technologies
Tenets of SOA
Although there is no official standard for SOA,the community seems to agree on four basic tenets as the guiding principles for achieving an SOA. They are:
• Service boundaries are explicit.
• Services are autonomous.
• Clients and services share contracts, not code.
• Compatibility is based on policy. compatibility兼容性
Let’s look at each of these in greater detail.
Service boundaries are explicit
Services are responsible for exposing a specific set of business functionality through a well-defined contract,where the contract describes a set of concrete operations and messages supported by the service.
Services completely encapsulate the coordination of calls to business components in response to operations it exposes to clients,as Figure 1-8 illustrates.
Figure 1-8 Services encapsulate business components and data access
Implementation details behind the service are unknown to clients so that any technology platform could be invoked behind the service without impact to the client.
In addition,the location of the service isn’t important to the client as long as the client knows where to reach it.
Enterprise Services,.NET Remoting,ASMX,and WCF all support this tenet.
With Enterprise Services and .NET Remoting,the boundary and contract are defined by the public operations of the serviced component or remote component,respectively.
In the case of Enterprise Services,the contract is described as a type library,while with .NET Remoting the contract is a shared CLR interface.
As for ASMX and WCF,contracts are described in Web Services Description Language (WSDL),an interoperable standard.
All of these technologies also support location transparency in one respect or another.
That is,the contract is independent of the location of the service in all cases.
Note:Where WCF improves on earlier technologies in support of explicit boundaries is in the way contract design and deployment are handled.
With WCF,you explicitly define the contract and opt-in every operation and data element that you intend to expose publicly.
WCF also goes beyond location transparency with protocol transparency,meaning you can expose services over any number of protocols.
Services are autonomous
Services encapsulate business functionality,but they must also encapsulate other dependencies of the business tier.
In this way the entire service should be moveable or even replaceable without impact to other services or system functionality as illustrated in Figure 1-9.
Figure 1-9 Services are location transparent
As I mentioned before,a service represents a major chunk of business functionality that owns its own business components,data access components and data storage if applicable.
It should be able to perform key functions without external dependencies. This is what is meant by atomicity.
Part of atomicity also dictates the following:
• The service boundary must act as an independent unit for versioning.
Changes to business components may require versioning the service contract, for example.
• The service boundary is the deployment boundary for callers.
• The service must operate in isolation and be fault-tolerant. That is,exceptions behind the service tier should not impact other services.
Note:Atomicity is largely influenced by design,but WCF does enable atomicity by providing a clear approach to contract versioning,a flexible approach to deployment,and certainly handles fault isolation if services are hosted by the same process.
Clients and services share contracts, not code
Given the first SOA tenet,that service boundaries are explicit,it only makes sense that this boundary be the law as far as how clients interact with services.
That means that the contract must not change once published,or must at a minimum remain backward compatible to existing clients—and this requires discipline.
In theory,contracts are not tied to a particular technology or platform,but this is not actually an official requirement of SOA—only a strong tendency.
Thus,you could say that serviced components,ASMX web services,and WCF services all support this tenet since they all are capable of publishing a contract that is consumed by clients without sharing code (type libraries or WSDL,respectively).
This is where .NET Remoting falls down, since it relies on sharing CLR types, a .NET-specific construct.
Note:The beauty of WCF is that it uses interoperable contract definitions (WSDL) for all types of services—regardless of the communication protocols used to reach those services.
Compatibility is based upon policy
While contracts describe the business functionality available at a service boundary,policy describes other constraints,such as communication protocols,security requirements,and reliability requirements.
Enterprise Services and .NET Remoting don’t really have a way to publish such policy requirements,but ASMX with Web Services Enhancements (WSE) and WCF do.
Policy is actually an extension to WSDL that can describe access constraints in a way that clients can be aware of them and invoke services in a compatible manner.
Note:WCF support for policy is completely hidden from the developer—it is automatically included with the WSDL document based on how you configure WCF service for features such as security and reliability.
Big SOA, Little SOA
The problem with discussing the tenets of SOA in the strictest sense is that levels of compliance may vary based on the scenario.
On the one hand,SOA is a big business buzzword tossed into conversations at board meetings,at executive briefings,and in hallway conversations between C-level executives.
At this level,however,SOA really refers to connecting disparate systems across application,department,corporate,and even industry boundaries.
This is what I call Big SOA.
The other use for the term SOA is to describe how applications are designed as chunks of business functionality that are isolated behind explicit service boundaries.
I call this Little SOA.
Big SOA is an Enterprise Architect (EA) activity.
The EA cares about connecting heterogeneous systems that may originate from different vendors.
For example,you can connect HR,Payroll,CRM,and possibly other applications across the organization to achieve a business goal.
In some cases,it is even useful to control messaging between systems and track usage with an Enterprise Service Bus (ESB)—a term that also means many things,
but in this case I refer to the ability to pass all messaging through a common service for tracking and routing purposes.
In short,Big SOA is about connecting entire systems through their respective service boundaries.
Little SOA is a Software Architect (SA) activity.
The SA cares about designing a system that may encapsulate functionality behind service boundaries to achieve reuse,maintainability,version control,visibility,orchestration,and other benefits.
These services may never see the light of day outside the application to which they belong.
On the other hand,some internal application services may also be exposed for public access to facilitate communications and interoperability with other applications.
If applications don’t expose public services,it becomes a challenge to connect applications.
Note:Little SOA enables Big SOA.
The distinction between approaches in SOA is important because of the level of strictness in applying SOA tenets.
For example,it isn’t always possible to completely isolate business components,business entities,and data tiers between services in the same system.
Data is usually highly relational within a system,such that different areas of business functionality share common data stores and entities.
Figure 1-10 illustrates an application with three services: Accounts,Customers,and Reporting.
Figure 1-10 Sharing data between services is sometimes unavoidable
Accounts Service and Customers Service each expose operations to their respective types,but Accounts data is related to Customers in the system;
thus,there isn’t a pure separation between the tables required to support each service.
At the same time,both Accounts and Customers also provide access to business functionality and CRUD operations (Create,Read,Update,Delete)
that can be considered completely independent of one another—thus the need for separate services.
The Reporting Service, in fact, needs to access all tables to aggregate results.
In a pure SOA play,each service would have sole ownership over its data tables,and services would have to communicate with one another to access those tables,even for reporting.
This can create unnecessary overhead and complexity within a system.
Instead,Figure 1-10 illustrates a way to support sharing relational tables behind the service boundary by coordinating relational results at the database,possibly via stored procedures.
This way,the vertical assemblies associated with a service are completely owned by the service,
and if a particular service,such as Reporting,requires access to multiple relational tables that are also accessed by other services,
the data access layer coordinates this result for the service.
While serialized business entities may be shared between services,business and data access components are not.
Services can always call other downstream services to share functionality when service isolation is clear cut
and the overhead of the service call makes sense—for example when services provides core functions such as document generation or messaging.
The point is that not all four tenets of SOA can be followed to the letter when designing services within an application.
When application services are exposed to Big SOA in most cases the entire application is deployed with the service,thus the shared entities and data stores are implied parts of the atomic service.
Note:In this book,I’ll be focusing on how you deploy WCF services as part of an enterprise application. In other words, Little SOA.
Service Oriented Architecture的更多相关文章
- Service Oriented Architecture and WCF 【转】
http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF Introduction This a ...
- SOA (面向服务的架构)-Service Oriented Architecture
SOA (面向服务的架构) 编辑 面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立 ...
- service oriented architecture 构造分布式计算的应用程序的方法 面向服务的架构 分解技术
zh.wikipedia.org/wiki/面向服务的架构 [程序功能做为服务] 面向服务的体系结构(英语:service-oriented architecture)是构造分布式計算的应用程序的方法 ...
- Web service standards: SOAP, REST, OData, and more
Web service standards: SOAP, REST, OData, and more So far, we've covered the components of a web ser ...
- WCF Windows Service Using TopShelf and ServiceModelEx z
http://lourenco.co.za/blog/2013/08/wcf-windows-service-using-topshelf-and-servicemodelex/ There are ...
- 理解web service 和 SOA
什么是SOA? SOA的全称为Service Oriented Architecture,即面向服务架构.这是一种架构理念.它的提出是在企业计算领域将耦合的系统划分为松耦合的无状态的服务.服务发布出来 ...
- 【转帖】Service Discovery: 6 questions to 4 experts
https://highops.com/insights/service-discovery-6-questions-to-4-experts/ What’s Service Discovery? I ...
- Service Discovery in WCF 4.0 – Part 1 z
Service Discovery in WCF 4.0 – Part 1 When designing a service oriented architecture (SOA) system, t ...
- 小白日记54:kali渗透测试之Web渗透-补充概念(AJAX,WEB Service)
补充概念 AJAX(异步javascript和XML) Asynchronous javascript and xml 是一个概念,而非一种新的编程语言,是一组现有技术的组合 通过客户端脚本动态更新页 ...
随机推荐
- [jquery]高级篇--获取div子元素
参考: http://zhidao.baidu.com/link?url=IfeQQBn1xMLqWvwdkKbQYJ8mC6ciGi_8M1NYkm6iQ-kXBMX2f2ylN-ckzFLiynn ...
- Attribute (一)
本文导读 1.概念 2.自定义一个 Attribute 概念 Attribute是一个特殊的类,我们知道 .NET 程序集 具有自描述的特性(由于元数据),Attribute和.NET的元 ...
- 【HeadFirst设计模式】12.复合模式
定义: 复合模式结合两个或以上的模式,组成一个解决方案,解决一再发生的一般性问题. 要点: MVC模式是复合模式,结合了观察者模式.策略模式和组合模式. 模型使用了观察者模式,以便观察者更新,同时保存 ...
- Python3 内建模块 hashlib、itertools、HTMLParser、urllib
Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 什么是摘要算法呢?摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一个长度固定的数据串(通常用16进制 ...
- C#获取运行程序的进程ID
C#获取运行程序的进程ID [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern int G ...
- 【转】MSSQL获取指定表的列名信息,描述,数据类型,长度
/* --作用:根据特定的表名查询出字段,以及描述,数据类型,长度,精度,是否自增,是否为空等信息 --作者:wonder QQ:37036846 QQ群:.NET顶级精英群 ID:124766907 ...
- linux批量修改文件名的shell脚本
linux中批量修改文件名的shell脚本代码,主要是使用了rename,结合shell,喜欢的朋友可以参考下 使用 rename 命令 ======================== NAME ...
- 《Junit实战》读书笔记
核心原则:任何没有经过自动测试的程序功能都可以当做不存在 单元测试框架的大三规则: 1.每个单元测试都必须独立于其他所有单元测试而运行 2.框架应该以单个测试为单元来检测和报告错误 3.应该易于定义要 ...
- Delphi中的GetEnumName和GetEnumValue的使用方法
利用TypInfo单元的GetEnumName和GetEnumValue可以遍历任意枚举类型,并获取其名称和值.下面是示例Demo. uses TypInfo; ... procedure TForm ...
- oracle服务介绍
按照windows 7 64位 安装oracle 11g R2中的方法成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为: 1. Oracle ORCL VSS Writer Ser ...