您的位置:首页 > 运维架构 > 网站架构

基于REST与Web架构的构想

2016-12-01 17:07 357 查看
之前学过基于SOAP的WebSerivce,最近在研究REST,不得不看Fielding的那篇博士论文《Architectural Styles and the Design of Network-based Software Architectures》,在转入正文之前,发现他对架构是什么的总结也很不错:

Software architecture research investigates methods for determining how best to partition a system, how components identify and communicate with each other, how information is communicated, how elements of a system can evolve independently, and how all of
the above can be described using formal and informal notations.

 

在学习一个新名词之前,我习惯将它与我之前熟悉的名词进行一个比较,如果这个名词不是一个全新的事物的话。虽然这样定位可能不一定那么准确,因为任何新名词的出现都是基于其特有的某些功能,但是这样能够帮助我快速地对新名词建立起基本的概念,在学习的时候不至于迷失掉。

 

因为对SOA有一定了解,那对于REST,我也来对应一下。从小的范围讲,我可以把

REST与SOAP对应起来,

JSON和XML对应起来,

SOA和ROA(Resource Oriented Architecture)对应起来。

当然,从广义地讲,REST也被看做一种架构风格。

REST (Representational State Transfer) is an architectural style that is seen as an alternative to SOAP-based web services

 

深入浅出REST:http://www.infoq.com/cn/articles/rest-introduction里列出了REST的关键原则:

为所有“事物”定义ID
将所有事物链接在一起
使用标准方法
资源多重表述
无状态通信
 

当然,很多时候不会有一个权威的解释,有很多争论,需要自己去理解。还有一个思路就是看看围绕这个新名词的开源项目都有哪些,每个的定位和竞争项目,这样也能反过来帮助理解这个概念。

 

RESTEasy:http://www.jboss.org/resteasy

RESTEasy is a JBoss project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications.
It is a fully certified and portable implementation of the JAX-RS specification. JAX-RS is a new JCP specification that provides a Java API
for RESTful Web Services over the HTTP protocol.

 

Restlethttp://www.restlet.org/

Restlet is a comprehensive yet lightweight RESTful web framework for Java that lets you embrace the architecture style of the Web (REST) and benefit from its simplicity and scalability. By leveraging our innovative framework, you can start blending your
web services, web sites and web clients into uniform web applications!

 

Jerseyhttp://jersey.java.net/

Jersey is the open source, production quality, JAX-RS (JSR 311) Reference Implementation for building RESTful Web services. But, it is also more than the Reference Implementation. Jersey provides an API so that developers may extend Jersey to suit their
needs. The governance policy is the same as the one used in the GlassFish project. We also use the same two licenses - CDDL 1.1 and GPL 2 with CPE - so, you can pick which one suites your needs better.

 

RESTEasy、Restlet和Jersey可以和CXF对比起来看。

 

Jettison: 读写JSON的工具集,用在CXF和XStream内 http://jettison.codehaus.org/
Jettison is a collection of Java APIs (like STaX and DOM) which read and write JSON. This allows nearly transparent enablement of JSON based web services in services frameworks like CXF or XML serialization frameworks like XStream.

 

 

如何具体使用REST?

在infoq上有篇文章“Simple JAVA and .NET SOA interoperability(”http://www.infoq.com/articles/REST-INTEROP)介绍了如何使用REST的风格来实现Java和.Net的集成,而且扩展性比较好。注意,这里使用的是REST的风格,而不是真正的RESTful,只是将请求以REST风格的方式包装,然后放在SOAP和message上来使用。之所以在这里引用,因为里面谈到了用.net/java来实现client/server时可选的工具集,可以借鉴一下。

 

因为Web Service更多地是用来解决异构平台的集成问题,所以任何一种标准技术得到广泛的支持很重要,因为Microsoft是SOAP/ws-*阵营的坚定支持者,所以看看微软是否支持REST也很重要。

The new WCF Web Programming Model supports REST Design

http://www.infoq.com/news/2007/05/wcf-web-programming-model

 

Camel与Restlet的集成:http://camel.apache.org/restlet.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: