RESTful服务最佳实践——(一)

本文主要读者

该最佳实践文档适用于对RESTful Web服务感兴趣的开发人员,该服务为跨多个服务的组件提供了较高的可靠性和一致性。按照本文的指导,可快速、广泛、公开地为内外部客户采用。

本文中的指导原则同样适用于工程师们,他们希望使用这些依据最佳实践原则开发的服务。虽然他们更加关注缓存、代理规则、监听及安全等相关方面,但是该文档能作为一份涵盖所有种类服务的总指南。

另外,通过从这些指导原则,管理人员了解到创建公共的、提供高稳定性的服务所需花费的努力,他们也可从中受益。

引言

现今已有大量关于RESTful Web服务最佳实践的相关资料(详见本文最后的相关文献部分)。由于创作的时间不同,许多资料中的内容是矛盾的。此外,想要通过查阅文献来了解这种服务的发展,是不太可取的。为了了解RESTful这一概念,至少需要查阅三到五本相关文献,而本文将能够帮你加速这一过程–摒弃多余的讨论,最大化地提炼出REST的最佳实践和规范。

与其说REST是一套标准,REST更像是一种原则的集合。除了六个重要的原则外就没有其他的标准了。实际上,虽然有所谓的“最佳实践”和标准,但这些东西都和宗教斗争一样,在不断地演化。

本文围绕REST的普遍问题提出了意见和仿食谱式的讨论,并通过介绍一些简单的背景知识对创建真实情境下的预生产环境中一致的REST服务提供知识。本文收集了来自其他渠道的信息,经历过一次次的失败后不断改进。

但对于REST模式是否一定比SOAP好用仍有较大争议(反之亦然),也许在某些情况下仍需要创建SOAP服务。本文在提及SOAP时并未花较大篇幅来讨论它的相对优点。相反由于技术和行业在不断进步,我们将继续坚持我们的假设–REST是当下设计web服务的最佳方法。

第一部分概述REST的含义、设计准则和它的独特之处。第二部分列举了一些小贴士来记忆REST的服务理念。之后的部分则会更深入地为web服务创建人员提供一些细节的支持和讨论,来实现一个能够公开展示在生产环境中的高质量REST服务。


原文如下


Who Should Read This Document

This best-practices document is intended for developers who are interested in creating RESTful Web services that provide high reliability and consistency across multiple service suites. By following these guidelines, services are well positioned for rapid, widespread, public adoption by both internal and external clients.

The guidelines in this document are also appropriate for support engineers where they desire to services developed using these best practices. While their concerns may be focused on caching practices, proxy rules, monitoring, security and such, this document may be useful as an overarching service documentation guide of sorts.

Additionally, management personnel may benefit from these guidelines by endeavoring to understand the effort required to create services that are publicly consumable and offer high levels of consistency across their service suites.

Introduction

There are numerous resources on best practices for creating RESTful web services (see the Resources section at the end of this document). Many of the available resources are conflicting, depending on when they were written. Plus, reading and comprehending several books on the subject in order to implement services “tomorrow” is not doable. In order to facilitate the quick uptake and understanding of RESTful concepts, without requiring the reading of at least three to five books on the subject, this guide is meant to speed up the process—condensing REST best practices and conventions into just the high points with not a lot of discussion.

REST is more a collection of principles than it is a set of standards. Other than its over-arching six constraints nothing is dictated. There are “best practices” and de-facto standards but those are constantly evolving—with religious battles waging continuously.

Designed to be brief, this document provides recommendations and some cookbook-style discussion on many of the common questions around REST and provides some short background information to offer support for effective creation of real-world, production-ready, consistent RESTful services. This document aggregates information available in other sources, adapting it with experience gained through hard knocks.

There is still considerable debate as to whether REST is better than SOAP (and vice versa), and perhaps there are still reasons to create SOAP services. While touching on SOAP, this document won’t spend a lot of time discussing the relative merits. Instead, because technology and the industry marches on, we will proceed with the assumption that leveraging REST is the current best practice for Web service creation.

The first section offers an overview of what REST is, its constraints, and what makes it unique. The second section supplies some quick tips as little reminders of REST service concepts. Later sections go more in depth to provide the Web service creator more support and discussion around the nitty-gritty details of creating high-quality REST services capable of being publicly exposed in a production environment.

没有更多推荐了,返回首页