• WCF学习系列一【WCF Interview Questions-Part 1 翻译系列】


    WCF Interview Questions – Part 1

    This WCF Tutorial is a collection of most frequently asked interview questions about Windows Communication Foundation (WCF) covering the beginner to professional level.

    这个WCF教程,是WCF常见问题的集合,它主要面向WCF初学者的专业水平。

    Following are the links to other posts in this WCF Questions Series:

    下面是WCF系列问答教程中的一部分:

    1. WCF Service Interview Questions – Part 1
    2. WCF Service Interview Questions – Part 2
    3. WCF Service Interview Questions – Part 3
    4. WCF Service Interview Questions – Part 4

    Note: Please look into the Top 10 WCF Interview Questions also.

    注意:同时请关注前10个WCF问题: Top 10 WCF Interview Questions

    frequently asked questions[FAQ]:常见问答

    MCSD Exam: 70-487

    1. What is WCF?【什么是WCF】
    2. Why to use WCF? or What are the advantages of using WCF?【为什么要使用WCF,或者WCF有哪些优点】
    3. What are the core components of WCF Service?【WCF服务,核心的组件是?】
    4. What are the new features introduced in WCF 4.5?【WCF 4.5版本中介绍了哪些新特性】
    5. What is the difference between WCF and ASMX Web services?【WCF和ASMX Web服务之间的不同是什么?】
    6. What are the Endpoints in WCF? or Explain ABCs of endpoint?【WCF的节点是什么?或者解释一两点出来】
    7. What is the difference between Service EndPoint and Client Endpoint?【服务节点和客户端节点有什么不同?】
    8. What is a WCF Binding? How many different types of bindings available in WCF?【什么是WCF绑定,WCF中允许哪些类型的绑定?】
    9. What is WebHttpBinding in WCF?【WCF中WebHttpBinding是什么?】
    10. Can we have multiple endpoints for different binding types in order to serve different types of clients?【为了服务不同类型的客户端,我们可以有多个不同类型的绑定节点么?】
    11. What are the hosting options for WCF Services? Explain.【WCF的托管选项是什么?请解释。】

    What is WCF?【什么是WCF】

    Microsoft refers WCF as a programming platform that is used to build Service-Oriented applications. Windows Communication Foundation is basically a unified programming model for developing, configuring and deploying distributed services.  Microsoft has unified all its existing distributed application technologies (e.g. MS Enterprise Services, ASMX web services, MSMQ, .NET Remoting etc) at one platform i.e. WCF. Code name for WCF was Indigo. Below diagram clearly explains it:

          微软把WCF作为,用于构建面向服务的应用程序的编程平台。Windows Communication Foundation基本上是一个统一的编程模型开发、配置和部署分布式服务。微软统一了现有的分布式应用程序【例如MS Enterprise Services, ASMX web services, MSMQ, .NET Remoting 等等】集中在一个平台上,也就是WCF。为WCF取名为Indigo,下面的图表清晰的解释了:

    Windows Communication Foundation

    Why to use WCF? or What are the advantages of using WCF?

    为什么使用WCF,它的优点是?

    Advantages of WCF 支持面向服务的架构;简单、可靠、安全;便于协同操作;一个服务可以服务多个客户端;可扩展。

     

    • Service Orientation is one of the key advantages of WCF. We can easily build service-oriented applications using WCF.【面向服务是WCF关键的优点。我们使用WCF可以很简单的构建面向服务的应用程序。】
    • If compared with ASMX web services, WCF service provides reliability and security with simplicity.【和ASMX Web 服务相比,WCF服务提供了可靠性,安全性,简单性】
    • As oppose to .NET Remoting, WCF services are interoperable.【相对.NET Remoting,WCF服务是可以互操作的。】
    • Different clients can interact with same service using different communication mechanism. This is achieved by using service endpoints. A single WCF service can have multiple endpoints. So, developer will write code for service once and just by changing configuration (defining another service endpoint), it will be available for other clients as well.【不同的客户端,和同一个服务的交互,可以使用不同的通信机制。这可以通过使用服务节点实现。一个简单的WCF服务可以有多个节点。因此,开发者只需要写一次服务端的代码,然后仅仅通过改变配置(定义其他的服务节点),那么这个服务,将会同时可以被其他的客互端使用。】
    • Extensibility is another key advantage of WCF.  We can easily customize a service behavior if required.【可扩展是WCF另外一个关键性的优点,如果有需要的话,我们可以很简单的定制服务的行为。】

    What are the core components of WCF Service?【WCF的关键组件是什么】

    A WCF service has at least following core components.【一个WCF服务,至少需要下面的关键组件】
    • Service Class:  A service class implementing in any CLR-based language and expose at least one method.
           服务类:一个服务类是基于任何CLR基础的语言实现的,并且至少暴露一个方法。
    • Hosting Environment: a managed process for running service.
           托管环境:为运行服务管理进程。
    • Endpoint: a client uses it to communicate with service.
           节点:客户端使用节点和服务端通信。
    • Core WCF Components

    What are the new features introduced in WCF 4.5?【WCF 4.5版本中介绍了哪些新特性】

    Windows Communication Foundation v4.5 was released with a number of cool features. Here we simply list down most important features but you can find thorough detail about each feature with helping code snippet in 7 parts series of new features in WCF 4.5. These important features are:

    Windows Communication Foundation v4.5发布了一些很酷的特点。这里我们仅仅列出最重要的特点,但是你可以从这篇文章中parts series of new features in WCF 4.5.找到每个特性的深入细节的代码片段。这些重要的特性是:

    • Simplified Configuration files【简化的配置文件】
    • ToolTip and Intellisense support【工具提示和智能感知的支持】
    • Task-based asynchronous Programming Model【基于任务的异步编程模型】
    • BasicHttpsBinding support【BasicHttpsBinding支持】
    • Single WSDL Document【单个的WSDL文件】
    • WCF Configuration Validation【WCF配置验证】
    • ASP.NET Compatibility Mode changed【ASP.NET兼容模型改变】
    • Contract First Development【Contract First开发】
    • Multiple Authentication Types【多个身份验证类型】
    • XmlDictionaryReaderQuotas default value changed【XmlDictionaryReaderQuotas默认值改变】
    • UDP Transport Support【支持UDP传输】
    • and many more…【更多....】

    For more on key WCF 4.5 features, please follow here.【想要了解更多WCF 4.5的特性,请看这:  follow here

    What is the difference between WCF and ASMX Web services?【WCF和ASMX Web服务之间的不同是什么?】

    The basic difference is that ASMX web service is designed to send and receive messages using SOAP over HTTP only. While WCF service can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, Named Pipes etc).ASMX Web Services Vs WCFYou can find detailed discussion on WCF Vs ASMX Web services here.

    基本区别是,ASMX web服务是使用HTTP上的SOAP,仅仅用于发送和接收消息。而WCF可以在任何传输协议(HTTP, TCP/IP, MSMQ, Named Pipes etc)上,使用任何格式(默认是SOAP)交换信息。在这儿,WCF Vs ASMX Web services ,你可以找到更多关于WCF和ASMX Web服务的讨论。

    What are the Endpoints in WCF? or Explain ABCs of endpoint?【WCF的节点是什么?或者解释一两点出来】

    For WCF services to be consumed, it’s necessary that it must be exposed; Clients need information about service to communicate with it. This is where service endpoints play their role.

    随着WCF讨论的继续,很有必要弄清楚什么是WCF;客户端需要服务的信息来通信,这就是服务节点所扮演的角色。
    A service endpoint has three basic elements or also called ABCs of an endpoint i.e. Address, Binding and Contract.

    一个服务节点有三个基本的元素,或者称作ABCs节点,那就是Address, Binding and Contract.

    ABC's of WCF EndPoint

    • AddressIt defines “WHERE”. Address is the URL that identifies the location of the service.
       Address:它定义了“哪里”,Address是一个URL,它定义了服务的位置。
    • BindingIt defines “HOW”. Binding defines how the service can be accessed.
           Binding:它定义了“怎样”,Binding定义了如何访问服务。
    • ContractIt defines “WHAT”. Contract identifies what is exposed by the service.
           Contract:它定义了“什么”。Contract确定了,服务公开了什么。
    • WCF Endpoint

    What is the difference between Service EndPoint and Client Endpoint?【服务端节点和客户端节点有什么不同?】

    As we already understood the concept of an Endpoint and it’s ABC (Address, Binding, Contract). Both Service and Client Endpoint has same ABC but we think in different perspective while working with them. We can differentiate between Service and Client Endpoint with respect to Address, Binding and Contract as:

    我们已经理解了节点的概念,知道了它有ABCs-->【Address, Binding, Contract】,服务端节点和客户端节点都同样有ABCs,但是我们可以从不同的角度来思考、使用它们。我们可以根据 Address, Binding and Contract,从以下几个方面来区分服务端节点和客户端节点:

     

    Service Endpoint【服务端节点】

    Client Endpoint【客户端节点】

    WHERE: URL of hosted service.【托管服务的URL】 WHERE: where to connect with hosted service.【连接托管服务】
    WHAT: bindings being used.【使用绑定】 WHAT: binding supported by service.【服务支持的绑定】
    CONTRACT: Service Contract i.e. interfaces【服务契约,例如接口。】 CONTRACT: what to pass and expect while communicating with service.【和服务通信的时候传递,期望值

    What is a WCF Binding? How many different types of bindings available in WCF?【什么是WCF绑定,WCF中允许哪些类型的绑定?】

    Bindings in WCF actually defines that how to communicate with the service. Binding specifies that what communication protocol as well as encoding method will be used. Optionally, binding can specify other important factors like transactions, reliable sessions and security.
    Another WCF Tutorial gives more detailed understanding of Binding concept in WCF.

    There are different built-in bindings available in WCF, each designed to fulfill some specific need.

         WCF中的Bindings,实际上定义了如何与服务进行通信.绑定指定了通信的协议还有使用的编码的方法。可选地,Binding可以指定其他重要因素,如事务,可靠的Sessions和安全性。另外的一片文章:WCF Tutorial给出了更多WCF中Binding概念的细节。

    下面这些不同的内置绑定在WCF中,都是可行的,每一个都是实现一些特定的需要。

    • basicHttpBinding
    • wsHttpBinding
    • netNamedPipeBinding
    • netTcpBinding
    • netPeerTcpBinding
    • netmsmqBindingWCF Bindings

    For details on different binding types, please follow the link to WCF bindings.

    想要了解很多不同的绑定类型,请看这个链接的文章:WCF bindings.

    What is a WebHttpBinding in WCF?【WCF中WebHttpBinding是什么?】

    WebHttpBinding is the one that is used for creating WCF RESTful services. In Windows Communication Foundation v3.5, Microsoft introduces support for building RESTful services. REST (Representational State Transfer) is an architectural design that uses HTTP the way it should be used.

          WebHttpBinding 被用来创建:WCF RESTful services,在WCF 3.5中,微软就支持创建RESTful 服务。REST (Representational State Transfer)是一个使用HTTP的设计结构。

    Instead of using HTTP just as a transport (in case of SOAP-based WCF Services), RESTful WCF services uses full features of HTTP (for all CRUD Operations including Create, Retrieve, Update and Delete).

    You can find WebHttpBinding in action as in below configuration screenshot.

          代替使用HTTP作为运输(在基于SOAP的WCF下), RESTful WCF services uses full features of HTTP(可以做所有的CRUD操作,包括增删查改。)你可以在下面的配置中找到WebHttpBinding 。

    WebHttpBinding

    Can we have multiple endpoints for different binding types in order to serve different types of clients?【为了服务不同类型的客户端,我们可以有多个不同类型的绑定节点么?】

    Yes, we can have multiple endpoints for different binding types. For example, an endpoint with wsHttpBinding and another one with netTcpBinging.
    是的,对于不用的绑定类型,我们可以有多个节点。例如一个节点上带有wsHttpBinding ,另外一个节点上有netTcpBinging。

    What are the hosting options for WCF Services? Explain.【WCF的托管选项是什么?请解释。】

    For a service to host, we need at least a managed process, a ServiceHost instance and an Endpoint configured. Possible approaches for hosting a service are:

    对于一个服务托管,我们至少需要一个管理进程,ServiceHost实例和一个节点配置。,下面的这些都是可以为服务托管的方法:

    • Hosting in a Managed Application/ Self Hosting【托管在一个托管的应用程序中/自我托管】
    • Hosting on Web Server【托管在Web服务器上】
      • IIS 6.0 (ASP.NET Application supports only HTTP)【IIS 6.0 ASP.NET应用程序仅仅支持HTTP】
      • Windows Process Activation Service (WAS) i.e. IIS 7.0 supports HTTP, TCP,【窗体进程激活服务(WAS),例如IIS 7.0 支持 HTTP,TCP,NamedPipes, MSMQ】
        NamedPipes, MSMQ.

    Next WCF Tutorial on Interview Questions and Answers in this series is about Proxy and Channel Factory, Concurrency and Throttling in WCF.

    下一篇WCF系列教程中,将会说道代理,渠道工厂,WCF的并发性和节流。

     

  • 相关阅读:
    leetcode 375. Guess Number Higher or Lower II
    leetcode 374. Guess Number Higher or Lower
    转 PHP中exec、system等函数调用linux命令问题
    转 PHP 使用 Redis
    转 Vim操作
    转 php simple test
    转 手把手教你最简单的开源项目托管GitHub入门教程
    Bootstrap开启模态框后对数据处理(标记模态框的开启与关闭状态)
    java必会的英语单词
    Service和Servlet的区别
  • 原文地址:https://www.cnblogs.com/caofangsheng/p/5492287.html
Copyright © 2020-2023  润新知