﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-走自己的路-随笔分类-SOA, SCA, JBI, BPEL and OSGI </title><link>http://www.blogjava.net/ldd600/category/32142.html</link><description>路漫漫其修远兮，吾将上下而求索</description><language>zh-cn</language><lastBuildDate>Sat, 15 Aug 2009 16:15:30 GMT</lastBuildDate><pubDate>Sat, 15 Aug 2009 16:15:30 GMT</pubDate><ttl>60</ttl><item><title>java端RESTful web services的几种实现方式</title><link>http://www.blogjava.net/ldd600/archive/2009/08/13/291018.html</link><dc:creator>叱咤红人</dc:creator><author>叱咤红人</author><pubDate>Thu, 13 Aug 2009 07:27:00 GMT</pubDate><guid>http://www.blogjava.net/ldd600/archive/2009/08/13/291018.html</guid><wfw:comment>http://www.blogjava.net/ldd600/comments/291018.html</wfw:comment><comments>http://www.blogjava.net/ldd600/archive/2009/08/13/291018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ldd600/comments/commentRss/291018.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ldd600/services/trackbacks/291018.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: java端RESTful web services的几种实现方式&nbsp;&nbsp;<a href='http://www.blogjava.net/ldd600/archive/2009/08/13/291018.html'>阅读全文</a><img src ="http://www.blogjava.net/ldd600/aggbug/291018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ldd600/" target="_blank">叱咤红人</a> 2009-08-13 15:27 <a href="http://www.blogjava.net/ldd600/archive/2009/08/13/291018.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>RESTful vs SOAPy</title><link>http://www.blogjava.net/ldd600/archive/2009/07/31/289209.html</link><dc:creator>叱咤红人</dc:creator><author>叱咤红人</author><pubDate>Fri, 31 Jul 2009 00:40:00 GMT</pubDate><guid>http://www.blogjava.net/ldd600/archive/2009/07/31/289209.html</guid><wfw:comment>http://www.blogjava.net/ldd600/comments/289209.html</wfw:comment><comments>http://www.blogjava.net/ldd600/archive/2009/07/31/289209.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ldd600/comments/commentRss/289209.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ldd600/services/trackbacks/289209.html</trackback:ping><description><![CDATA[&nbsp;
<p><strong><span style="font-size: 10pt; font-family: Arial">Rest and Restful web services</span></strong></p>
<p><span style="font-size: 10pt; font-family: Arial">There are currently two schools of thought in developing web services: the traditional, standards-based approach (SOAP) and conceptually simpler and the trendier new kid on the block (REST). The origin of the term "REST" comes from the famous thesis from Roy Fielding describing the concept of Representative State Transfer (REST). REST is an architectural style that can be summed up as four verbs (GET, POST, PUT, and DELETE from HTTP 1.1) and the nouns, which are the resources available on the network (referenced in the URI). The verbs have the following operational equivalents:</span></p>
<p><span style="font-size: 10pt; font-family: Arial">HTTP&nbsp;&nbsp;&nbsp;&nbsp; CRUD Equivalent</span></p>
<p><span style="font-size: 10pt; font-family: Arial">==============================</span></p>
<p><span style="font-size: 10pt; font-family: Arial">GET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read</span></p>
<p><span style="font-size: 10pt; font-family: Arial">POST&nbsp;&nbsp;&nbsp;&nbsp; create,update,delete</span></p>
<p><span style="font-size: 10pt; font-family: Arial">PUT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; create,update</span></p>
<p><span style="font-size: 10pt; font-family: Arial">DELETE&nbsp;&nbsp; delete</span></p>
<p><span style="font-size: 10pt; font-family: Arial">The emergence of the RESTful style of web services was a reaction to the more heavy-weight SOAP-based standards. In RESTful web services, the emphasis is on simple point-to-point communication over HTTP using plain old XML (POX) or JSON. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Java API for RESTful Web Services specification is in final state, JAX-RS is an annotation-based API for implementing RESTful web services, based on HTTP. In addition to the Sun-provided reference implementation, Jersey, other implementations are available (in various stages of completion): as part of the popular Restlet framework, the JBoss RESTeasy project , and as part of the Apache CXF web services stack.</span></p>
<p><strong><span style="font-size: 10pt; font-family: Arial">Rest vs SOAP:</span></strong></p>
<p><span style="font-size: 10pt; font-family: Arial">Representation</span></p>
<p><span style="font-size: 10pt; font-family: Arial">A REST-style web service might be every bit as subtle and complicated as a SOAP-based service. The RESTful approach tries to simplify matters by taking what HTTP, with its MIME type system, already offers: built-in CRUD operations, uniformly identifiable resources, and typed representations that can capture a resource's state. The key to the REST methodology is to write Web services using a representation that is already well known and widely used: the URI. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Complexity</span></p>
<p><span style="font-size: 10pt; font-family: Arial">REST as a design philosophy tries to isolate application complexity at the endpoints, that is, at the client and at the service. A service may require lots of logic and computation to maintain resources and to generate adequate representation of resources—for instance, large and subtly formatted XML documents—and a client may require significant XML processing to extract the desired information from the XML representations transferred from the service to the client. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Bandwidth</span></p>
<p><span style="font-size: 10pt; font-family: Arial">RESTful approach keeps the complexity out of the transport level, as a resource representation is transferred to the client as the body of an HTTP response message. By contrast, a SOAP-based service inevitably complicates the transport level because a SOAP message is encapsulated as the body of a transport message; for instance, an HTTP or SMTP message. SOAP requires messages within messages, whereas REST does not. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Performance</span></p>
<p><span style="font-size: 10pt; font-family: Arial">SOAP uses XML generally bloats your messages quite a bit. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Something like POX or JSON would be more compact and maybe faster to serialize / deserialize.</span></p>
<p><span style="font-size: 10pt; font-family: Arial">Payloads of SOAP are significantly larger which are slower to assemble, transport, parse, validate and process.</span></p>
<p><span style="font-size: 10pt; font-family: Arial">Security</span></p>
<p><span style="font-size: 10pt; font-family: Arial">A typical SOAP request will use POST to communicate with a given service. And without looking into the SOAP envelope, there's no way to know whether that request simply wants to query data or delete entire tables from the database</span></p>
<p><span style="font-size: 10pt; color: black; font-family: Arial">As for authentication and authorization, SOAP places the burden in the hands of the application developer. The REST methodology instead takes into account the fact that Web servers already have support for these tasks. </span></p>
<p><span style="font-size: 10pt; font-family: Arial">Domain Design</span></p>
<p><span style="font-size: 10pt; font-family: Arial">SOAP services defined in Web Services Description Language (WSDL) emphasize contracts and actions. In contrast, REST focuses on direct addressing and manipulation of resources, which is more compatible with the domain-driven approach.</span></p>
<p><span style="font-size: 10pt; font-family: Arial">Defects</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">There is less definition of interface, especially the method interface</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Hard to make strongly typed objects to work with it in server side code &nbsp;</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Only works over HTTP, but SOAP can work on HTTP, FTP, MIME, JMS, SMTP and etc</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Calls to REST are restricted by HTTP Verbs (GET, POST, PUT, DELETE.. etc)</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">No automatic xml schema validation</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Less SOA-style than SOAP</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Developer has less control on security than SOAP, SOAP has ws-*(ws-security, ws-trust, ws-policy and etc), SAML, XACML and etc</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; tab-stops: list 21.0pt"><span style="font-size: 6.5pt; font-family: Wingdings">l<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10pt; font-family: Arial">Routing is network-controlled, but SOAP can make client to control routing explicitly through SOAP headers, WS-Addressing and etc</span></p>
<p><strong><span style="font-size: 10pt; font-family: Arial">Implementation</span></strong></p>
<p><span style="font-size: 10pt; font-family: Arial">How to implement Restful web services, there are three kinds of methods recently:</span></p>
<ul style="margin-top: 0in" type="disc">
    <li style="tab-stops: list .5in"><span style="font-size: 10pt; font-family: Arial">Make use of provider and dispatch twins of SOAP-based web service</span>
    <li style="tab-stops: list .5in"><span style="font-size: 10pt; font-family: Arial">Implement Restful HTTPServlets</span>
    <li style="tab-stops: list .5in"><span style="font-size: 10pt; font-family: Arial">JAX-RS, annotation-based implementation</span> </li>
</ul>
<img src ="http://www.blogjava.net/ldd600/aggbug/289209.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ldd600/" target="_blank">叱咤红人</a> 2009-07-31 08:40 <a href="http://www.blogjava.net/ldd600/archive/2009/07/31/289209.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>