<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adam Trachtenberg &#187; rest</title>
	<atom:link href="http://www.trachtenberg.com/blog/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trachtenberg.com/blog</link>
	<description>Thoughts on PHP, eBay, and too many technical topics for my family's liking.</description>
	<lastBuildDate>Tue, 24 Aug 2010 21:39:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>REST vs HTTP+POX vs SOAP</title>
		<link>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/</link>
		<comments>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 08:29:34 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[pox]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/</guid>
		<description><![CDATA[<a href="http://www.intertwingly.net/blog/2006/11/05/POX-and-SOAP">Sam</a> and <a href="http://www.crummy.com/2006/11/05/2">Leonard</a> ponder the differences among them. Here's the deal:

<ol>
<li>REST == HTTP GET</li>
<li>HTTP+POX == HTTP GET &#038; POST</li>
<li>SOAP == HTTP POST, with interop issues</li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.intertwingly.net/blog/2006/11/05/POX-and-SOAP">Sam</a> and <a href="http://www.crummy.com/2006/11/05/2">Leonard</a> ponder the differences among them. Here&#8217;s the deal:</p>
<ol>
<li>REST == HTTP GET</li>
<li>HTTP+POX == HTTP GET &#038; POST</li>
<li>SOAP == HTTP POST, with interop issues</li>
</ol>
<p><span id="more-665"></span><br />
When I&#8217;m talking to people about web services, and I hear them use various terms, this is what I feel they&#8217;re talking about most of the time.</p>
<p><strong>REST</strong></p>
<p>REST almost always indicates HTTP GET with a query string. The results are probably XML, but lately they could also be JSON.</p>
<p>No other HTTP verbs are used (especially PUT and DELETE), and it&#8217;s highly likely that all requests are routed through the same URI.</p>
<p>For example:</p>
<p>http://api.example.org/rest?action=search&#038;query=trachtenberg</p>
<p><strong>HTTP+POX</strong></p>
<p>Nobody uses this term. However, there are some web services that, while not &#8220;true REST,&#8221; use more than HTTP GET. I place them in this category.</p>
<p>These likely exist because the service allows you to submit a large quantity of data that is not human readable, so it does not make sense to place as part of a query string. Blobs of HTML and pictures come to mind.</p>
<p>For example, the eBay &#8220;XML API&#8221;. You can submit items over eBay web services. Since the item description is pure HTML, it exceeded the maximum query string length our web server would accept at the time.</p>
<p>Thus, the eBay XML API was invented: you HTTP POST an XML document, we return an XML document.</p>
<p>Again, like REST, there&#8217;s no concept of resources. Everything goes through the same URI. The action is indicated either as part of the query string or in POST body. (Or both, as in the eBay case.)</p>
<p><strong>SOAP</strong></p>
<p>SOAP is identical to HTTP+POX, except that you&#8217;re required to use XML Namespaces and XML Schema.</p>
<p>You are also going to have interop issues when trying to generate the SOAP envelope to send or parse the SOAP envelope that&#8217;s returned.</p>
<p>XML Namespaces and XML Schema are minor headaches, but people are willing to deal with them. People understand that, in theory, namespaces are good, even if XML Namespaces are a little funky.</p>
<p>XML Schema can be confusing. However, it does allow you to validate the response, which most people find to be somewhat useful. The fact that XML Schema may not be the best way to describe XML data is a different issue.</p>
<p>If SOAP merely had these two issues, people would work through it. The real problem with SOAP is that the specification is so confusing, people can&#8217;t build interoperable clients and servers. This drives people mad.</p>
<p>People know how to generate arbitrary XML (it&#8217;s just text after all) and send a HTTP POST request. They also know how to parse XML, particularly when they know ahead of time what they should expect. (That&#8217;s why PHP 5&#8217;s SimpleXML extension is a great web services client.)</p>
<p>What they cannot do is decipher a WSDL file to determine what crazy combination of XML the server is expecting (especially when the server is not following the standard). And, assuming they can get through that, they cannot figure out how to repeatedly hammer their SOAP client into producing the magical combination of XML necessary to placate the SOAP server.</p>
<p>That&#8217;s the difference between HTTP+POX and SOAP.</p>
<p>It&#8217;s not the complexity. Well, it&#8217;s not complexity in terms of needing to build up a large document. It&#8217;s complexity in terms of trying to understand the hundreds of pages of XML specifications to generate the request and not having good examples of working XML documents to crib off of.</p>
<p>As to whether the message name should go in the URI? Nobody cares.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=665&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/11/06/rest-vs-httppox-vs-soap/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>REST Web Services, the Book</title>
		<link>http://www.trachtenberg.com/blog/2006/11/06/rest-web-services-the-book/</link>
		<comments>http://www.trachtenberg.com/blog/2006/11/06/rest-web-services-the-book/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 07:29:08 +0000</pubDate>
		<dc:creator>Adam Trachtenberg</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.trachtenberg.com/blog/2006/11/06/rest-web-services-the-book/</guid>
		<description><![CDATA[Sam Ruby and Leonard Richardson are writing a book on <a href="http://www.intertwingly.net/blog/2006/11/03/REST-Web-Services">REST Web services</a>. Very exciting. I love reading Sam's blog and watching him untangle standards.

Looking at the <a href="http://www.crummy.com/writing/REST-Web-Services/">Table of Contents</a>, I'm particularly interested in "Appendix A: HTTP status codes and when to use each one." (Yes, I am serious.)]]></description>
			<content:encoded><![CDATA[<p>Sam Ruby and Leonard Richardson are writing a book on <a href="http://www.intertwingly.net/blog/2006/11/03/REST-Web-Services">REST Web services</a>. Very exciting. I love reading Sam&#8217;s blog and watching him untangle standards.</p>
<p>Looking at the <a href="http://www.crummy.com/writing/REST-Web-Services/">Table of Contents</a>, I&#8217;m particularly interested in &#8220;Appendix A: HTTP status codes and when to use each one.&#8221; (Yes, I am serious.)<br />
<span id="more-664"></span><br />
When I designed &#8220;<a href="https://www.dudewheresmyusedcar.com/">Dude, Where&#8217;s My Used Car</a>,&#8221; my mashup between eBay Motors and Google Maps, I churned through a number of different ways to signal failure. My biggest issue is that there&#8217;s so many places my request can fail, I&#8217;m not sure how to &#8220;correctly&#8221; represent that back inside my mashup.</p>
<p>For example, in response to a user-generated action (such as filling out a form and clicking submit), my mashup initiates a HTTP GET AJAX request (well, AJAJ because I&#8217;m using JSON instead of XML) which hits my web server. I then use PHP to parse the request, generate a corresponding SOAP request to eBay&#8217;s web service gateway, wait for result, pick it apart and convert the bits I want to JSON. This data is then passed back to the browser, where I (well, <a href="http://dojotoolkit.org/">Dojo</a>, actually) evals it.</p>
<p>When everything works, everything works.</p>
<p>But what happens when the user enters an invalid ZIP Code? eBay will return an error, and I&#8217;d like to proxy this back to the application, so I can toss up a message.</p>
<p>Should I return 200 OK and pass back the message? That&#8217;s one option, but I&#8217;d prefer not to need to check the data structure to see if I got the normal data I expected or some nasty error instead.</p>
<p>Besides, Dojo lets me specify a separate error handler callback function. It seems a cleaner design to handle all the errors there. But then I can&#8217;t return 200. What to use instead? 400 Bad Request?</p>
<p>Then there&#8217;s cases where the error is not the user&#8217;s fault, but either my fault or eBay&#8217;s fault. What should I do if eBay returns a SOAP envelope my PHP script can&#8217;t parse? 502 Bad Gateway? Or if the eBay server returns a SOAP Fault? The same 500 Internal Server Error I got back from eBay?</p>
<p>Should I not let my web server&#8217;s interaction with eBay bleed back into browser?</p>
<p>Here&#8217;s another example: when eBay&#8217;s server is too busy, it returns <a href="http://developer.ebay.com/DevZone/migration/docs/BestPractices/RetryCode.htm">Error Code 10007</a>. I can retry (and hopefully fix the problem) inside of my PHP script without even needing to message back to the browser. But if I did ultimately give up retrying, should I pass back 503 Service Unavailable? Am I on the hook for translating between SOAP and REST in my server-side proxy PHP script?</p>
<p>Maybe I can use 4xx codes for problems which are &#8220;user generated&#8221; in some form. These are things which require the user to take an action to remedy. And for things which are broken but otherwise outside of the control of the user (such as my SOAP client being unable to understand eBay&#8217;s SOAP response) I can use 5xx.</p>
<p>I actually like this idea, but I&#8217;m wondering if there&#8217;s a &#8220;standard&#8221; way to indicate errors and failures in a AJAX application. I can&#8217;t find one, but I&#8217;m not very familiar with what&#8217;s out there.</p>
<p>PS: My vote is to leave off the &#8220;With Ruby&#8221; part of the title, and go with plain &#8220;REST Web Services&#8221;.</p>
<img src="http://www.trachtenberg.com/blog/?ak_action=api_record_view&id=664&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trachtenberg.com/blog/2006/11/06/rest-web-services-the-book/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

