ATLAS Bridges Rock
ATLAS is the relative newcomer to the AJAX scene. I haven’t spent much time looking at the client side pieces, but I have taken a good look at the server side pieces.
The one feature that really stands out is the XML to JSON marshalers that ship in the box. ATLAS introduces a nice (well, as nice as you can get with XML) syntax for declaratively describing the mapping between a Web Service (REST and SOAP are both supported among others) and your JSON schema.
At the bottom of this blog is a simple example that I hacked up last night that shows mapping an Amazon Web Service to JSON.
The transform element describes the XPath mapping that shreds the XML document into JSON. It returns an array of objects that each contain a url property that points to the album cover art for the Artist passed in the Artist parameter.
The reason why I love this feature is that it’s just so natural to marshal data to browsers as JSON. It also nicely works around the ‘I can only talk to the origin server’ security restriction imposed by most browsers on XmlHttpRequest calls, since your origin server now acts as a proxy (or a bridge) to the web service that you want to call.
You can even cache results on your origin server if you add a cache directive to your bridge. Kudos to the ATLAS team for making this just work.
<bridge namespace="Test" className="Amazon" >
<proxy type="Microsoft.Web.Services.BridgeRestProxy"
serviceUrl="http://webservices.amazon.com/onca/xml" />
<method name="getAlbums">
<input>
<parameter name="Service" value="AWSECommerceService" serverOnly="true" />
<parameter name="Version" value="2005-03-23" serverOnly="true" />
<parameter name="Operation" value="ItemSearch" serverOnly="true" />
<parameter name="SubscriptionId" value="your key goes here" serverOnly="true" />
<parameter name="SearchIndex" value="Music" serverOnly="true" />
<parameter name="Condition" value="All" serverOnly="true" />
<parameter name="ResponseGroup" value="Images" serverOnly="true" />
<parameter name="Artist" />
</input>
<transforms>
<transform type="Microsoft.Web.Services.XPathBridgeTransformer">
<data>
<attribute name="selector" value="//a:Item" />
<dictionary name="namespaceMapping">
<item name="a" value="http://webservices.amazon.com/AWSECommerceService/2005-03-23" />
</dictionary>
<dictionary name="selectedNodes">
<item name="url" value="a:SmallImage/a:URL" />
</dictionary>
</data>
</transform>
</transforms>
</method>
</bridge>


23. May, 2006 







No comments yet... Be the first to leave a reply!