WCF - Architecture

WCF has a layered architecture that offers ample support for developing various distributed applications. The architecture is explained below in detail.

wcf有一个分层的架构,为开发不同的分布式应用提供了足够的支持。架构图的细节如下图所示

Contracts   契约

The contracts layer is just next to the application layer and contains information similar to that of a real-world contract that specifies the operation of a service and the kind of accessible information it will make. Contracts are basically of four types discussed below in brief:

契约层紧挨着应用层,它包含的信息和现实世界中的界面类似,指定了服务的操作,服务产生的可访问信息的类型。简单来说,契约有以下4种类型

  • Service contract - This contract provides information to the client as well as to the outer world about the offerings of the endpoint, and the protocols to be used in the communication process.

  • Data contract - The data exchanged by a service is defined by a data contract. Both the client and the service has to be in agreement with the data contract.

  • Message contract - A data contract is controlled by a message contract. It primarily does the customization of the type formatting of the SOAP message parameters. Here, it should be mentioned that WCF employs SOAP format for the purpose of communication. SOAP stands for Simple Object Access Protocol.

  • Policy and Binding - There are certain pre-conditions for communication with a service, and such conditions are defined by policy and binding contract. A client needs to follow this contract.

1.服务契约:提供给信息给客户端以及外部世界,信息是关于endpoint提供的,以及进程间通讯使用的协议

2.数据契约:由服务进行交换的数据,定义在数据契约中。 客户端和服务端都必须与数据契约保持一致

3.消息契约:数据契约由消息契约进行控制。它主要用来处理soap消息参数格式的自定义类型。这里,它应该提到wcf所使用的用于通信目的的soap格式。 soap表示Simple Object Access Protocol.

4.策略和绑定:有一些和服务进行通信的前提条件,比如由策略以及绑定契约所定义的条件。客户端需要按照这个契约来处理

Service Runtime   服务运行时

The service runtime layer is just below the contracts layer. It specifies the various service behaviors that occur during runtime. There are many types of behaviors that can undergo configuration and come under the service runtime.

service runtime层在契约层下面。它指明了在运行时发生的各种服务行为。有许多类型的行为可以进行配置,并且在服务运行时出现。

  • Throttling Behavior - Manages the number of messages processed.

  • Error Behavior - Defines the result of any internal service error occurrence.

  • Metadata Behavior - Specifies the availability of metadata to the outside world.

  • Instance Behavior - Defines the number of instances that needs to be created to make them available for the client.

  • Transaction Behavior - Enables a change in transaction state in case of any failure.

  • Dispatch Behavior - Controls the way by which a message gets processed by the infrastructure of WCF.

  • Concurrency Behavior - Controls the functions that run parallel during a client-server communication.

  • Parameter Filtering - Features the process of validation of parameters to a method before it gets invoked.

1.限制行为:控制能够处理的消息的数量

2.错误行为:定义了任何内部错误发生时的结果

3.元数据行为:详细说明了元数据对外部世界的可用性

4.实例行为:定义了需要创建的实例的数量,并使得他们对客户端可用

5.事务行为:万一遇到故障,确保事务会有一个变化

6.调度行为:控制wcf底层处理消息的方式

7.并发行为:控制客户端和服务端通信时的并发功能

8.参数过滤:实现了在调用方法之前,检查参数的有效性

Messaging  消息

This layer, composed of several channels, mainly deals with the message content to be communicated between two endpoints. A set of channels form a channel stack and the two major types of channels that comprise the channel stack are the following ones:

消息层,由若干个信道组成。消息主要用于处理2个终结点之间的通信内容。一系列的信道形成了信道栈,组成信道栈的2个主要信道类型如下:

  • Transport Channels - These channels are present at the bottom of a stack and are accountable for sending and receiving messages using transport protocols like HTTP, TCP, Peer-to-Peer, Named Pipes, and MSMQ.

  • Protocol Channels - Present at the top of a stack, these channels also known as layered channels, implement wire-level protocols by modifying messages.

1.传输信道:传输信道位于栈的底部,负责使用传输协议来发送和接收消息,使用的协议包括HTTP,TCP,P2P,命名管道以及消息队列

2.协议信道:协议信道在栈的顶部,协议信道也被称为分层信道,通过无线协议来修改消息

Activation and Hosting   激活与宿主

The last layer of WCF architecture is the place where services are actually hosted or can be executed for easy access by the client. This is done by various mechanisms discussed below in brief.

wcf架构的最后一层,是服务实际寄宿的地方或者是执行起来后客户端可以轻易访问。简单来说,这是由一下各种机制来完成的

  • IIS - IIS stands for Internet Information Service. It offers a myriad of advantages using the HTTP protocol by a service. Here, it is not required to have the host code for activating the service code; instead, the service code gets activated automatically.

  • Windows Activation Service - This is popularly known as WAS and comes with IIS 7.0. Both HTTP and non-HTTP based communication is possible here by using TCP or Namedpipe protocols.

  • Self-hosting - This is a mechanism by which a WCF service gets self-hosted as a console application. This mechanism offers amazing flexibility in terms of choosing the desired protocols and setting own addressing scheme.

  • Windows Service - Hosting a WCF service with this mechanism is advantageous, as the services then remain activated and accessible to the client due to no runtime activation.

1.IIS:互联网信息服务,通过一个使用HTTP协议的服务,它可以提供大量的优势。它不要求host代码来激活service代码,service code会自行激活。

2.WAS:windows激活服务,这个适合IIS7.0一起发布的。通过使用TCP或者命名管道协议,不管是基于http或者非http的通信都是可能的

3.自托管:wcf服务通过自托管成一个控制台应用来实现的机制,这个机制在选择所需的协议以及设置它自己的地址模式时有这惊人的灵活性

4.windows服务:使用这种机制托管wcf是有益的,因为不需要运行时激活,服务就可以一直保持激活状态并且对客户端可以访问

最后附上中文的架构图:图片是百度搜索的,不知道出处是哪里

WCF - Architecture的更多相关文章

  1. WCF服务编程 读书笔记——第1章 WCF基础(2)

    续:第1章 WCF基础(1) 元数据交换 服务有两种方案可以发布自己的元数据.一种是基于HTTP-GET协议提供元数据, 另一种则是后面将要讨论的使用专门的终结点的方式.WCF能够为服务自动提供基于H ...

  2. Service Oriented Architecture and WCF 【转】

    http://www.codeproject.com/Articles/515253/Service-Oriented-Architecture-and-WCF Introduction This a ...

  3. WCF基础

    初入职场,开始接触C#,开始接触WCF,那么从头开始学习吧,边学边补充. SOA Service-Oriented Architecture,面向服务架构,粗粒度.开放式.松耦合的服务结构,将应用程序 ...

  4. WCF 学习篇

    写在前面 自从运用了.NET Remoting 之后,就想系统的学习下WCF,因为WCF是对现有分布式通信技术的整合.主要以 <WCF全面解析> 这本书为主,园子的资料和网上资料为辅,来学 ...

  5. Difference between WCF and Web API and WCF REST and Web Service

    The .Net framework has a number of technologies that allow you to create HTTP services such as Web S ...

  6. WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】

    http://www.topwcftutorials.net/2012/10/wcf-faqs-part3.html WCF Interview Questions – Part 3 This WCF ...

  7. WCF学习系列四--【WCF Interview Questions – Part 4 翻译系列】

    WCF Interview Questions – Part 4   This WCF service tutorial is part-4 in series of WCF Interview Qu ...

  8. WCF 、Web API 、 WCF REST 和 Web Service 的区别

    WCF .Web API . WCF REST 和 Web Service 的区别 The .Net framework has a number of technologies that allow ...

  9. 关于WCF服务在高并发情况下报目标积极拒绝的异常处理

    最近弄了个wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好好的活着.于是开始查原因. 一般来说目标积极拒绝(TCP 10061)的异常主要是 ...

随机推荐

  1. 安装oracle 12c遇到问题

    安装前步骤:更改用户账户控制设置:从不通知  出现 "SEVERE: [FATAL] [INS-30014] 无法检查指定的位置是否位于 CFS 上" 解决办法:重新设置hosts ...

  2. NSMutableAttributedString(富文本)的简单使用

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  3. 无限大整数相加算法的C语言源代码

    忙里偷闲,终于完成了无限大整数相加算法的C语言代码,无限大整数相加算法的算法分析在这里. 500位的加法运行1000次,不打印结果的情况下耗时0.036秒,打印结果的情况下耗时16.285秒. 下面是 ...

  4. [.Net MVC] 使用 log4net 日志框架

    项目:后台管理平台 意义:项目开发中提出增加日志功能,对关键的操作.程序运行中的错误信息进行记录,这对程序部署后的调试有很大意义. 注:本文只是对网上搜集的信息进行了整合,以备今后查询. 关键字:.N ...

  5. Codevs 3289 花匠 2013年NOIP全国联赛提高组

    3289 花匠 2013年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 花匠栋栋种了一排花,每株花都 ...

  6. config spec

    config_spec Rules for selecting versions of elements to appear in a view APPLICABILITY Product Comma ...

  7. 九度OJ 1283 第一个只出现一次的字符

    题目地址:http://ac.jobdu.com/problem.php?pid=1283 题目描述: 在一个字符串(1<=字符串长度<=10000,全部由大写字母组成)中找到第一个只出现 ...

  8. Sass:一种CSS预处理器语言

    http://sass-lang.com/ Sass是一种CSS预处理器语言,通过编程方式生成CSS代码.因为可编程,所以操控灵活性自由度高,方便实现一些直接编写CSS代码较困难的代码. 同时,因为S ...

  9. 不使用border-radius,实现一个可复用的高度和宽度都自适应的圆角矩形

    现在css3支持圆角矩形,但是为了兼容性问题,虽然比较麻烦,但还是有必要了解一下以下方法. 在一个div内,包含8个div,控制这个8个div的height.margin以及border属性值,以达到 ...

  10. AVAudioRecorder 录制音频

    AVFoundation 中使用AVAudioRecorder 类添加音频录制功能是非常简单的, AVAudioRecorder构建与Audio Queue Services之上是一个功能强大且代码简 ...