{"id":9,"date":"2005-07-18T11:26:24","date_gmt":"2005-07-18T15:26:24","guid":{"rendered":"http:\/\/www.coactus.com\/blog\/?p=9"},"modified":"2005-07-18T11:37:59","modified_gmt":"2005-07-18T15:37:59","slug":"towards-truly-document-oriented-web-services","status":"publish","type":"post","link":"http:\/\/www.coactus.com\/blog\/2005\/07\/towards-truly-document-oriented-web-services\/","title":{"rendered":"Towards truly document oriented Web services"},"content":{"rendered":"<h3>In the beginning<\/h3>\n<p>For much of the first year or two in the life of Web services &#8211; and indeed all of their<br \/>\n<a href=\"http:\/\/www.xmlrpc.com\/stories\/storyReader$555\">history up to that point<\/a> &#8211;<br \/>\nthey were about remote procedure calls (RPC); exposing remote APIs across the Internet in order to facilitate machine-to-machine communication and ultimately, business-to-business integration over the Internet.<\/p>\n<p>It didn&#8217;t take very long however, for Web services proponents to realize that they needed to distance themselves from RPC and its well-deserved reputation as a poor large scale integration architectural style, due to the failure of systems such as <a href=\"http:\/\/www.corba.org\/\">CORBA<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/DCOM\">DCOM<\/a>, and<br \/>\n<a href=\"http:\/\/java.sun.com\/products\/jdk\/rmi\/\">RMI<\/a> to see any widespread use on the Internet.  So, sometime in 2000\/2001, collective wisdom in the space shifted towards a preference for &#8220;document oriented&#8221; services.  Vendors quickly jumped on board with upgraded toolkits, and that was that; documents were the New Big Thing.<\/p>\n<p>Unfortunately, the basic architectural assumptions underlying Web services at the time, didn&#8217;t change nearly enough to distance Web services from the problems of RPC.<\/p>\n<h3>What is &#8220;Document oriented&#8221;?<\/h3>\n<p>Respected Web services guru <a href=\"http:\/\/www.bowlight.net\/\">Anne Thomas Manes<\/a><br \/>\nsuccinctly (and unknowingly, it appears)<br \/>\n<a href=\"http:\/\/searchwebservices.techtarget.com\/ateQuestionNResponse\/0,289625,sid26_cid494324_tax289201,00.html\">describes the differences between RPC and document orientation<\/a>;<\/p>\n<blockquote>\n<p>Document style: <\/p>\n<pre>\r\n&lt;env:Body&gt; \r\n    &lt;m:purchaseOrder xmlns:m=\"someURI\"&gt; \r\n      ... \r\n    &lt;\/m:purchaseOrder&gt; \r\n  &lt;\/env:Body&gt;\r\n<\/pre>\n<p>RPC style: <\/p>\n<pre>\r\n&lt;env:Body&gt; \r\n    &lt;m:placeOrder xmlns:m=\"someURI\"&gt; \r\n      &lt;m:purchaseOrder&gt; \r\n        ... \r\n      &lt;\/m:purchaseOrder&gt; \r\n    &lt;\/m:placeOrder&gt; \r\n  &lt;\/env:Body&gt;\r\n<\/pre>\n<p>The bigger difference is how you encode the message. [&#8230;]<\/p>\n<\/blockquote>\n<p>While the encodings used were certainly different, each with its own not-insignificant pros and cons, what Anne failed to point out is that the RPC example <em>included an operation name<\/em> (&#8220;placeOrder&#8221;) while the document oriented example did not.  This constitutes an extremely significant architectural difference, as it tells us that Anne&#8217;s document example uses a <em>state transfer<\/em> style, while the RPC example does not.<\/p>\n<h3>State Transfer<\/h3>\n<p>State transfer styles, which include<br \/>\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/Message_Oriented_Middleware\">MOM<\/a>,<br \/>\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/EDI\">EDI<\/a>,<br \/>\n<a href=\"http:\/\/www4.desales.edu\/~dlm1\/it533\/class03\/pipe.html\">pipe and filter<\/a><br \/>\nand others, are characterized primarily by one architectural constraint; all the components expose the same application interface.  Actually, in most cases, including those three, the application interface is constrained to providing a <em>single<\/em> operation that one might call &#8220;processData&#8221; (it&#8217;s actually called &#8220;putData&#8221; in that pipe-and-filter description).  Each server component exposes this operation, enabling any client to submit data to it for processing.  In addition, because there&#8217;s only one operation, its use is implicit and therefore needn&#8217;t be included in the message.<\/p>\n<p>Allow me to reiterate my main point; Anne&#8217;s document oriented example above includes an implicit (&#8220;processData&#8221;) operation.<\/p>\n<h3>REST<\/h3>\n<p><a href=\"http:\/\/www.ics.uci.edu\/~fielding\/pubs\/dissertation\/rest_arch_style.htm\">REST<\/a> &#8211; REpresentational State Transfer &#8211; is, as the name suggests, also a state transfer style.  One of the interesting ways that REST differs from the others, is that rather than constrain the interface to the single &#8220;processData&#8221; operation, it allows any operation which is meaningful to all components (referred to as the <a href=\"http:\/\/www.ics.uci.edu\/~fielding\/pubs\/dissertation\/rest_arch_style.htm#sec_5_1_5\">&#8220;uniform interface&#8221;<\/a>).  An interesting side-effect of allowing more than one operation, is that it requires messages be <em>explicit<\/em> about the operation in use, since there obviously needs to be a way to disambiguate messages with the same document, but different operations.<\/p>\n<p>HTTP is the application protocol most closely associated with REST, largely because it was developed to respect many of REST&#8217;s constraints.  As it related to the uniform interface and explicit operations, HTTP provides a &#8220;POST&#8221; operation which is an alias for the aforementioned &#8220;processData&#8221; operation.  So, back to Anne&#8217;s example again, this HTTP message is semantically identical to her document oriented example;<\/p>\n<blockquote>\n<pre>\r\nPOST some-uri HTTP\/1.1\r\nHost: some-host.example.org\r\nContent-Type: application\/x-purchase-order+xml\r\n\r\n&lt;env:Body&gt; \r\n    &lt;m:purchaseOrder xmlns:m=\"someURI\"&gt; \r\n      ... \r\n    &lt;\/m:purchaseOrder&gt; \r\n  &lt;\/env:Body&gt;\r\n<\/pre>\n<\/blockquote>\n<p>Moreover, note that if the HTTP operation were different &#8211; say, if it were &#8220;PUT&#8221; instead of &#8220;POST&#8221; &#8211; then the message would no longer have semantics identical to Anne&#8217;s original document oriented example.  Yes, this means that the semantics of the message are a function of the application protocol being used, unlike conventional wisdom with Web services which suggests that message semantics should be <a href=\"http:\/\/builder.com.com\/5100-6389-5198198.html\">&#8220;protocol independent&#8221;<\/a>.<\/p>\n<h3>Conclusion<\/h3>\n<p>Hopefully this little note helps put in context the architectural relationship between the Web and document oriented Web services.  The relationship is closer than it appears in some important ways, yet more distant in others, likely as a result of the fact that Web services began with RPC, rather than with a truly document oriented architectural style.  Perhaps spelling this out explicitly, as I hope I&#8217;ve done here, will help more Web services proponents realize the importance of the Web to their objectives of integrating systems across the Internet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The move to loosely coupled, document oriented Web services is incomplete.  Next step, the Web.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"_links":{"self":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts\/9"}],"collection":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":0,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}