SOA理论与概念

Service-oriented architecture

维基百科

Service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. The basic principles of service-oriented architecture are independent of vendors, products and technologies.[1] A service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online.

面向服务架构SOA是一种软件设计风格,那么在这种风格下我们通过应用组件的方式向其他组件去提供服务,提供服务的方式是基于网络的一种通信协议。SOA的基本原则是独立于厂商、产品和技术。服务是一种功能的离散单元,他们可以通过远程的方式被访问可以进行独立的操作和更新,例如在线获取一个信用卡账单。

A service has four properties according to one of many definitions of SOA:[2]

  • It logically represents a business activity with a specified outcome.
  • It is self-contained.
  • It is a black box for its consumers.
  • It may consist of other underlying services.[3]

一个服务有四个属性根据soa诸多定义的一种来看

  • 从逻辑上来看,它会代表着一个业务活动会有指定的一个特定的结果
  • 服务是自包含的
  • 对于服务的消费者来说,它是黑盒
  • 一个服务可能包含其他的底层服务

Different services can be used in conjunction to provide the functionality of a large software application,[4] a principle SOA shares with modular programming. Service-oriented architecture integrates distributed, separately-maintained and -deployed software components. It is enabled by technologies and standards that facilitate components’ communication and cooperation over a network, especially over an IP network.

不通的服务可以联合起来被使用以提供一个大型的软件应用功能,一个SOA原则会共享模块化的编程,SOA集成了分布式的、单独去维护的以及单独部署的软件组件。它是由技术与标准来驱动的,使得组件基于网络的通信和协作成为可能,特别是通过IP网络。

Overview

In SOA, services use protocols that describe how they pass and parse messages using description metadata. This metadata describes both the functional characteristics of the service and quality-of-service characteristics. Service-oriented architecture aims to allow users to combine large chunks of functionality to form applications which are built purely from existing services and combining them in an ad hoc manner. A service presents a simple interface to the requester that abstracts away the underlying complexity acting as a black box. Further users can also access these independent services without any knowledge of their internal implementation.[5]

在SOA中,服务使用协议,这种协议描述了服务如何通过使用描述元数据传输和解析消息。元数据描述了两部分内容,一是服务功能特性二是服务质量特性。SOA旨在允许用户将一些大块的功能组合到一起,形成纯粹由现有服务构建的应用程序,并以特定的方式组合他们。服务向请求者提供一个简单接口,该接口以一种黑盒的形式抽象了底层的复杂性。此外,用户还可以访问这些独立的服务,而不需要知道它们的内部实现。

Defining concepts

The related buzzword service-orientation promotes loose coupling between services. SOA separates functions into distinct units, or services,[6] which developers make accessible over a network in order to allow users to combine and reuse them in the production of applications. These services and their corresponding consumers communicate with each other by passing data in a well-defined, shared format, or by coordinating an activity between two or more services.[7]

相关时髦的词语面向服务提倡服务之间松耦合。SOA将功能分离为不同的单元(或服务),开发人员可以通过网络访问这些单元或服务,以便允许用户在应用程序的生产中组合和重用它们。这些服务及其对应的消费者通过以定义良好的共享格式传递数据,或通过协调两个或多个服务之间的活动来彼此通信。

Principles

There are no industry standards relating to the exact composition of a service-oriented architecture, although many industry sources have published their own principles. Some of these[11][12][13][14] include the following:

面向服务的体系结构的确切组成目前还没有相关的行业标准,尽管许多行业来源已经发布了自己的原则。其中一些[11][12][13][14]包括以下内容:

  • Standardized service contract
    Services adhere to a standard communications agreements, as defined collectively by one or more service-description documents within a given set of services.

标准化的服务契约
服务遵循标准通信协议,由给定服务集合中的一个或多个服务描述文档共同定义。

  • Service reference autonomy (an aspect of loose coupling)
    The relationship between services is minimized to the level that they are only aware of their existence.

服务应用自治(松耦合的一个方面)
服务之间的关系被最小化到它们只知道它们的存在

  • Service location transparency (an aspect of loose coupling)
    Services can be called from anywhere within the network that it is located no matter where it is present.

服务定位透明化(松耦合的一个方面)
服务可以从网络中它所在的任何位置调用,无论它在哪里。

  • Service longevity
    Services should be designed to be long lived. Where possible services should avoid forcing consumers to change if they do not require new features, if you call a service today you should be able to call the same service tomorrow.

服务长寿
服务的设计应该是长期的。在可能的情况下,如果服务不需要新特性,就应该避免强制消费者进行更改,如果您今天调用服务,那么明天就应该能够调用相同的服务。

  • Service abstraction
    The services act as black boxes, that is their inner logic is hidden from the consumers.

服务抽象
服务充当黑盒,即它们的内部逻辑对消费者隐藏。

  • Service autonomy
    Services are independent and control the functionality they encapsulate, from a Design-time and a run-time perspective.

服务的自主权
服务是独立的,并且可以控制它们封装的功能,从设计期和运行期的角度来看。

  • Service statelessness
    Services are stateless, that is either return the requested value or give an exception hence minimizing resource use.

服务无状态
服务是无状态的,即要么返回请求的值,要么提供异常,从而最小化资源的使用。

  • Service granularity
    A principle to ensure services have an adequate size and scope. The functionality provided by the service to the user must be relevant.

服务粒度
确保服务具有足够大小和范围的原则。服务提供给用户的功能必须是相关的。

  • Service normalization
    Services are decomposed or consolidated (normalized) to minimize redundancy. In some, this may not be done, These are the cases where performance optimization, access, and aggregation are required.[15]

服务标准化
服务被分解或合并(规范化)以最小化冗余。在某些情况下,可能不需要这样做,这些情况下需要性能优化、访问和聚合

  • Service composability
    Services can be used to compose other services.

服务的可组合性
服务可用于组合其他服务。

  • Service discovery
    Services are supplemented with communicative meta data by which they can be effectively discovered and interpreted.

服务发现
服务由交流元数据补充,通过这些元数据可以有效地发现和解释服务。

  • Service reusability
    Logic is divided into various services, to promote reuse of code.

服务可重用性
逻辑被划分为各种服务,以促进代码的重用。

  • Service encapsulation
    Many services which were not initially planned under SOA, may get encapsulated or become a part of SOA.

服务封装
许多最初没有在SOA下计划的服务可能被封装或成为SOA的一部分

Patterns

Each SOA building block can play any of the three roles:

每个SOA构建块都可以扮演以下三个角色之一:

Service provider

服务提供者

It creates a web service and provides its information to the service registry. Each provider debates upon a lot of hows and whys like which service to expose, which to give more importance: security or easy availability, what price to offer the service for and many more. The provider also has to decide what category the service should be listed in for a given broker service[16] and what sort of trading partner agreements are required to use the service.

它创建一个web服务并将其信息提供给服务注册中心。每个提供者都在争论如何公开和为什么公开哪个服务,以及提供更多的重要性:安全性还是简单可用性,提供服务的价格等等。提供者还必须决定为给定的代理服务[16]列出哪些类别的服务,以及为了使用服务消费者需要哪种协议。

Service broker, service registry or service repository
服务代理

Its main functionality is to make the information regarding the web service available to any potential requester. Whoever implements the broker decides the scope of the broker. Public brokers are available anywhere and everywhere but private brokers are only available to a limited amount of public. UDDI was an early, no longer actively supported attempt to provide Web services discovery.

它的主要功能是使任何潜在的请求者都可以获得关于web服务的信息。无论谁实现这个broker都必须决定broker的范围。公共代理在任何地方都是可用的,但是私有代理只对有限数量的公众可用。UDDI是提供Web服务发现的早期尝试,不再受到积极支持。

Service requester/consumer
服务消费者

It locates entries in the broker registry using various find operations and then binds to the service provider in order to invoke one of its web services. Whichever service the service-consumers need, they have to take it into the brokers, bind it with respective service and then use it. They can access multiple services if the service provides multiple services.

它使用各种find操作定位到代理的入口,然后绑定到服务提供者上,以便调用其中一个web服务。无论服务消费者需要哪个服务,他们都必须将其纳入代理中,将其与相应的服务绑定,然后使用它。如果服务提供多个服务,则可以访问多个服务。

The service consumer–provider relationship is governed by a standardized service contract,[17] which has a business part, a functional part and a technical part.

服务消费者-提供者关系由标准化服务契约[17]控制,该契约包含业务部分、功能部分和技术部分。

Service composition patterns have two broad, high-level architectural styles: choreography and orchestration. Lower level enterprise integration patterns that are not bound to a particular architectural style continue to be relevant and eligible in SOA design.[18][19][20]

服务组合模式有两种广泛的高级体系结构样式:编排和编制。低层企业集成模式没有绑定到特定架构风格上可以继续在SOA设计中进行演化。

Implementation approaches

Service-oriented architecture can be implemented with web services.[21] This is done to make the functional building-blocks accessible over standard Internet protocols that are independent of platforms and programming languages. These services can represent either new applications or just wrappers around existing legacy systems to make them network-enabled.[22]

面向服务的体系结构可以用web service实现。这样做是为了使功能构建块可以通过标准Internet协议进行访问,它是独立于平台和编程语言的。这些服务可以表示成新的应用,或者只是现有遗留系统的包装器,以使它们通过网络访问。

Implementers commonly build SOAs using web services standards. One example is SOAP, which has gained broad industry acceptance after recommendation of Version 1.2 from the W3C[23] (World Wide Web Consortium) in 2003. These standards (also referred to as web service specifications) also provide greater interoperability and some protection from lock-in to proprietary vendor software. One can, however, also implement SOA using any other service-based technology, such as Jini, CORBA or REST.

实现者通常使用web service标准构建soa。SOAP就是一个例子,在W3C[23] (World Wide Web Consortium)于2003年推荐了1.2版之后,它获得了广泛的行业接受。这些标准(也称为web servie规范)还提供了更好的互操作性,并提供了对专有供应商软件的一些保护。但是,也可以使用任何其他基于服务的技术(如Jini、CORBA或REST)来实现SOA。

Architectures can operate independently of specific technologies and can therefore be implemented using a wide range of technologies, including:

架构者可以独立于特定的技术运行,因此可以使用广泛的技术来实现,包括:

Web services based on WSDL and SOAP
Messaging, e.g., with ActiveMQ, JMS, RabbitMQ
RESTful HTTP, with Representational state transfer (REST) constituting its own constraints-based architectural style
OPC-UA
WCF (Microsoft’s implementation of Web services, forming a part of WCF)
Apache Thrift
gRPC
SORCER

Implementations can use one or more of these protocols and, for example, might use a file-system mechanism to communicate data following a defined interface specification between processes conforming to the SOA concept. The key is independent services with defined interfaces that can be called to perform their tasks in a standard way, without a service having foreknowledge of the calling application, and without the application having or needing knowledge of how the service actually performs its tasks. SOA enables the development of applications that are built by combining loosely coupled and interoperable services.

实现可以使用这些协议中的一个或多个,例如,可以遵循符合SOA概念定义好的一个接口规范使用文件系统机制进行数据通信。关键是这些独立的服务拥有定义好的接口可以被调用以一种标准化的方式执行他们的任务,而不需要服务预先了解调用应用,也不需要应用知道或需要知道服务实际如何执行其任务。SOA支持通过组合松散耦合和互操作的服务来构建应用程序的开发。