Exchange 的 EWS 客户端设计概述EWS client design overview for Exchange

了解使用 EWS 为 Exchange 进行开发时的设计注意事项。Learn about the design considerations for developing with EWS for Exchange.

本文提供有关设计 Exchange Web 服务(EWS)应用程序的概述信息。This article provides overview information about designing an Exchange Web Services (EWS) application. 您可以使用此信息来确定 EWS 是否为您的应用程序正确的 API,如果是,则应使用哪种类型的客户端实现。You can use this information to determine whether EWS is the right API for your application, and if so, what type of client implementation you should use. 本文还提供了最佳实践信息,用于设计可将 Office 365、Exchange Online 和 Exchange 的版本从 Exchange 2007、一个代码库和目标目标本地 Exchange 服务器(与目标 Exchange Online 相关的重要决策点)组成的应用程序。This article also provides best practice information for designing applications that can target Office 365, Exchange Online, and versions of Exchange starting with Exchange 2007, in one code base, and important decision points for targeting on-premises Exchange servers versus targeting Exchange Online.

是否适合您的应用程序的 EWS API?Is EWS the right API for your application?

在开始设计应用程序之前,请务必考虑 EWS 是否为你提供了正确的 API。Before you begin to design your application, it is important to consider whether EWS is the right API for you. 如果要针对 Exchange Server 或 Exchange Online 进行开发,则 EWS 是首选的客户端访问技术。If you are developing against Exchange Server or Exchange Online, EWS is the preferred client access technology. 从 Exchange 2007 开始的 Exchange 版本的客户端访问开发主要是以 EWS 为重点。Client access development for versions of Exchange starting with Exchange 2007 has primarily been focused on EWS. 在 Outlook 中实施的新客户端访问功能使用 EWS,包括 Exchange 2007 中引入的外出(OOF)和可用性功能,以及 Exchange 2010 中引入的邮件提示和获取聊天室功能。New client access functionality that is implemented in Outlook uses EWS, including the Out of Office (OOF) and Availability features introduced in Exchange 2007, and the MailTips and Get Rooms functionality introduced in Exchange 2010. 这表示开发 Exchange 客户端应用程序的内部和外部合作伙伴在 EWS 中提交的投资。This represents a committed investment in EWS for both internal and external partners who develop Exchange client applications.

EWS 是您的 Exchange 客户端应用程序的主要客户端访问 API。EWS is the primary client access API for your Exchange client applications. 但是,在某些情况下,您可能会考虑其他用于客户端应用程序开发的 Exchange Api。However, in some cases, you might consider other Exchange APIs for client application development. 例如,Exchange ActiveSync 提供了与 EWS 相比的以下优势:For example, Exchange ActiveSync provides the following advantages over EWS:

  • 已对 XML 结构进行了标记,以使 Exchange ActiveSync 成为一种更紧凑的协议。The XML structure has been tokenized to make Exchange ActiveSync a more compact protocol.
  • Exchange ActiveSync 包含用于控制客户端访问和提供其他强健的企业移动消息解决方案的策略机制。Exchange ActiveSync contains a policy mechanism to control client access and to provide other robust enterprise mobile messaging solutions.

备注

您需要许可证才能开发 Exchange ActiveSync 客户端。You need a license in order to develop Exchange ActiveSync clients. 若要了解 Exchange ActiveSync 和 EWS 之间的差异,请参阅在 Exchange activesync 和 Exchange Web 服务(EWS)之间进行选择To learn about the differences between Exchange ActiveSync and EWS, see Choosing between Exchange ActiveSync and Exchange Web Services (EWS).

MAPI RPC over HTTP 是 Exchange 客户端应用程序的另一个可编程性选项。MAPI RPC over HTTP is another programmability option for Exchange client applications. 但是,MAPI RPC over HTTP 不提供直观的接口用于在客户端和服务器之间进行通信。However, MAPI RPC over HTTP does not provide an intuitive interface for communicating between clients and the server.

有关 Exchange 开发技术的详细信息,请参阅在 exchange 中浏览 EWS 托管 API、ews 和 web 服务For more information about Exchange development technologies, see Explore the EWS Managed API, EWS, and web services in Exchange.

EWS 客户端开发的选项Options for EWS client development

有几个选项可用于使用 EWS 针对 Exchange 进行开发。Several options are available for developing against Exchange by using EWS. 您的最佳选择将取决于您的组织的开发平台、工具、可用的实现和应用程序要求。The best option for you will depend on the development platform, tools, available implementations, and application requirements for your organization. 以下是可用于构建 EWS 客户端应用程序的四个主要选项:The following are the four primary options that are available for building EWS client applications:

  • EWS Managed APIThe EWS Managed API
  • EWS Java APIThe EWS Java API
  • EWS 自动生成代理The EWS autogenerated proxies
  • 自定义 EWS 客户端 APIA custom EWS client API

EWS 托管 APIEWS Managed API

EWS 托管 API是一个自定义 web 服务客户端。The EWS Managed API is a custom web service client. 它是用于 .NET Framework 应用程序的标准客户端访问 API。It is the standard client access API for .NET Framework applications.

以下是使用 EWS 托管 API 的一些优点:The following are some of the benefits of using the EWS Managed API:

  • 它提供直观的对象模型。It provides an intuitive object model.
  • 它简要介绍了 WSDL 和 schema 文件中的服务说明的复杂性。It abstracts the complexities of the service description in the WSDL and schema files.
  • 它包括客户端业务逻辑。It includes client-side business logic.
  • 它处理 web 请求和响应以及对象序列化和反序列化。It handles the web requests and responses and object serialization and deserialization.
  • 它是 Microsoft 支持的。It is Microsoft-supported.

但请注意,EWS 托管 API 并不是一个完整的解决方案。Note, however, that the EWS Managed API is not a complete solution. 在 EWS 托管 API 中不实现某些功能。Some functionality is not implemented in the EWS Managed API. 虽然 EWS 托管 API 不实现所有 EWS 功能,但它可能是客户端应用程序开发的最佳选择,原因如下:Although the EWS Managed API doesn't implement all EWS functionality, it might be the best choice for your client application development, for the following reasons:

  • 您可以使用 .NET Framework 进行开发。You can use the .NET Framework for development.
  • 它除了可实现 EWS 对象模型的大多数部分之外,还实现自动发现。It implements Autodiscover in addition to most parts of the EWS object model.
  • 它实现了在ExchangeService类中使用 EWS 的客户端业务逻辑。It implements client-side business logic for working with EWS, in the ExchangeService class.

出于以下任一原因,您可以选择使用 EWS web 服务 API 而不是 EWS 托管 API:You might choose to use the EWS web service API instead of the EWS Managed API for any of the following reasons:

  • 您的应用程序不使用 .NET Framework。Your application does not use the .NET Framework.
  • 您不希望分发 EWS 托管 API 程序集。You don't want to distribute the EWS Managed API assembly.
  • 您的应用程序使用在 EWS 托管 API 中未实现的功能。Your application uses features that aren't implemented in the EWS Managed API.

若要了解详细信息,请参阅EWS 托管 API 客户端应用程序入门To learn more, see Get started with EWS Managed API client applications.

备注

EWS 托管 API 现已作为 GitHub 上的开源项目推出。The EWS Managed API is now available as an open source project on GitHub. 你可以使用开源库进行以下操作:You can use the open source library to:

  • 为 API 提供缺陷修复和增强功能。Contribute bug fixes and enhancements to the API.
  • 在修补程序和增强功能在正式的版本中可用之前获取它们。Get fixes and enhancements before they are available in an official release.
  • 访问最全面且最新的 API 实现,将其用作参考或在新的平台上创建新库。Access the most comprehensive and up-to-date implementation of the API, to use as a reference or to create new libraries on new platforms.

欢迎你通过 GitHub 做出贡献We welcome your contributions via GitHub.

EWS Java APIEWS Java API

EWS Java API 是GitHub上的开放源代码项目,可由社区进行更新和扩展。The EWS Java API is an open source project on GitHub that can be updated and extended by the community. Stylistically 类似于Ews 托管 API ,并通过线路使用 ews SOAP 请求和响应。It is stylistically similar to the EWS Managed API and uses EWS SOAP requests and responses over the wire. 尽管不能使用 EWS Java API 访问所有EWS SOAP 操作,但在最近创建的开放源代码项目中,我们正在寻求社区弥补此缺口。Although you can't access all EWS SOAP operations by using the EWS Java API, with the recent creation of the open source project, we are looking to the community to bridge this gap. 请注意,具有适当支持合同的 Microsoft 支持将解决与 EWS SOAP 协议(而非 EWS Java API 本身)相关的任何问题。Note that Microsoft Support, with an appropriate support contract, will address any questions related to the EWS SOAP protocol but not the EWS Java API itself. GitHub上可下载和社区贡献的 EWS Java API。The EWS Java API is available for download and community contribution on GitHub.

EWS 自动生成代理EWS autogenerated proxies

自动生成的客户端 Api 是从 EWS WSDL 和 XML 架构定义生成的。Autogenerated client APIs are generated from the EWS WSDL and XML schema definitions. 客户端对象模型生成器可用于多种语言。Client object model generators are available for many languages. 通常情况下,自动生成的对象模型会管理对象的序列化和反序列化。In general, the autogenerated object models manage object serialization and deserialization. 它们不包括业务逻辑,并且自动生成过程通常会创建项目,以使对象模型不太直观,可供使用。They do not include business logic and the autogeneration process often creates artifacts that make the object model less intuitive to use. Exchange 支持涵盖客户端(而不是对象模型)发送和接收的 XML。Exchange support covers the XML that is sent and received by the client but not the object model.

自定义 EWS 客户端 APICustom EWS client API

对于某些使用一小部分 EWS 功能的应用程序,您可以创建自定义客户端 API 以与 Exchange 进行通信。For some applications that use a small set of EWS functionality, you might create a custom client API to communicate with Exchange. 这使您可以消耗更少的系统资源。This enables you to consume fewer system resources. 对于在内存有限的设备(如运行 .NET 微框架的客户端)上运行的客户端,这非常有用。This is useful for clients that run on memory-constrained devices, such as clients running the .NET Micro Framework.

EWS 客户端功能EWS client features

无论您选择哪种开发选项,都应考虑如何在客户端中实现 EWS 功能。Regardless of the development option that you choose, you should consider how EWS features are implemented in your client. 功能可用性基于应用程序的目标 EWS 架构版本。Feature availability is based on the EWS schema version that your application targets. 由于 EWS 架构是向后和向前兼容的,因此,如果您创建一个面向早期架构版本的应用程序(如 Exchange Server 2007 SP1),您的应用程序还将针对更高版本的架构版本(如 Exchange Server 2013 SP1 服务)以及 Exchange Online 运行。Because EWS schemas are backward- and forward-compatible, if you create an application that targets an earlier schema version, such as Exchange Server 2007 SP1, your application will also work against a later schema version, such as the Exchange Server 2013 SP1 service, as well as Exchange Online.

由于功能和功能更新由架构驱动,因此我们建议使用针对要在客户端应用程序中实现的 EWS 功能的最早通用基本代码。Because features and feature updates are driven by the schema, we recommend that you use the earliest common code base that targets the EWS features that you want to implement in your client application. 由于 Exchange 2007 SP1 架构包含几乎所有用于在 Exchange 存储中处理项目和文件夹的核心 Exchange 功能,因此许多应用程序可以面向 Exchange2007_SP1 版本。Many applications can target the Exchange2007_SP1 version, because the Exchange 2007 SP1 schema contains almost all the core Exchange functionality for working with items and folders in the Exchange store. 我们建议您为每个 EWS 架构版本维护代码派生。We recommend that you maintain code forks for each EWS schema version. 以下是当前可用的架构版本。The following are the schema versions that are currently available.

  <xs:simpleType name="ExchangeVersionType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Exchange2007" />
      <xs:enumeration value="Exchange2007_SP1" />
      <xs:enumeration value="Exchange2010" />
      <xs:enumeration value="Exchange2010_SP1" />
      <xs:enumeration value="Exchange2010_SP2" />
      <xs:enumeration value="Exchange2013" />
      <xs:enumeration value="Exchange2013_SP1" />
    </xs:restriction>
  </xs:simpleType>

架构版本在ExchangeVersionType简单类型中维护。The schema versions are maintained in the ExchangeVersionType simple type.

有关每个 EWS 架构版本中提供的功能的信息,请参阅Exchange 中的 EWS 架构版本For information about the features that are available in each EWS schema version, see EWS schema versions in Exchange.

本节内容In this section

另请参阅See also