使用GET方式设计URL的几个好处


XML.com: REST and the Real World

An Illustrative Example
UDDI is an example of a web service that could be made much more robust as a resource-centric web service. I'm not discussing the philosophical issues of UDDI's role in the web services world but the very concrete issue of how to get information into and out of it. These arguments will apply to most of the web services in existence, including stock quote services, airplane reservations systems, and so forth.

UDDI has a concept of a businessEntity representing a corporation. Businesses are identified by UUIDs. The Web-centric way to do this would have been to identify them by URIs. The simplest way to do this would be to make a businessEntity an XML document addressable at a URI like"http://www.uddi.org/businessEntity/ibm.com" or perhaps "http://www.uddi.org/getbusinessEntity?ibm.com". The difference between these two is subtle and does not have many technical implications so let's not worry about it.

You can think of "http://www.uddi.org/businessEntity" as a directory with files in it or a web service pulling data from a database. A wonderful feature of the Web is that there is no way to tell which it is just from looking at the URI. That is "loose coupling" in action.

Let's consider the implications of using HTTP-based URIs instead of UUIDs for business entities:

Anybody wanting to inspect that business entity would merely point their browser at that URI and look at the businessEntity record. An HTML version could be served to legacy browsers and the XML version to newer ones.
Anybody wanting to reference the businessEntity (in another web service or a document) could just use the URI.
Anybody wanting to incorporate the referenced information into another XML document could use an XLink, XPointer or XInclude.
Anybody wanting a permanent copy of the record could use a command line tool like "wget" or do a "Save As" from the browser.
Any XSLT stylesheet could fetch the resource dynamically to combine it with others in a transformation.
Access to the businessEntity could be controlled using standard HTTP authentication and access control mechanisms
Metadata could be associated with the businessEntity using RDF
Any client-side application (whether browser-based or not) could fetch the data without special SOAP libraries.
Two business entities could represent their merger by using a standard HTTP redirect from one businessEntity to another.
Editing and analysis tools like Excel, XMetaL, Word and Emacs could import XML from the URI directly using HTTP. They could write back to it using WebDAV.
UUIDs or other forms of location-independent addresses could still be assigned as an extra level of abstraction as demonstrated at purl.org.
The current UDDI API has a method called get_businessDetail. Under an address-centric model, that method would become entirely redundant and could thus be removed from the API. UDDI has several get_ methods that operate on data objects such as tModels and business services. These data objects could all be represented by logical XML documents and the methods could be removed. Note how we have substantially simplified the user's access to UDDI information. At the same time we've elevated the importance of XML and XML modeling in the UUDI system.

Business entities are not the only things in UDDI that should be identified by URI-addressable XML resources rather than SOAP APIs. In fact all of the data in a UDDI database could be represented this way.

Summary: Resources (data objects) are like children. They need to have names if they are to participate in society.

作者:车东 发表于:2004-10-06 02:10 最后更新于:2007-04-15 19:04
版权声明:可以转载,转载时请务必以超链接形式标明文章 的原始出处和作者信息及本版权声明

发表一个评论

(如果你此前从未在此 Blog 上发表过评论,则你的评论必须在 Blog 主人验证后才能显示,请你耐心等候。)

相关文章

关于

此页面包含了发表于2004年10月06日 夜间02时23分的 Blog 上的单篇日记。

此 Blog 的前一篇日记是 站外搜索命令:看看其他网站如何引用自己网站上的内容

此 Blog 的后一篇日记是 从MT2.6升级到MT3.x

更多信息可在 主索引 页和 归档 页看到。

Creative Commons License
此 Blog 中的日记遵循以下授权 Creative Commons(创作共用)授权.
Powered by
Movable Type 3.36