About the XML Interchange (REST) example

This application shows how XML transmitted over HTTP can be an effective interop mechanism across disparate Web application server technologies.

Overview

There are two dynamic web pages in this demo: the page that produces XML from a database query (called "XmlDataFeed"), and the page that consumes that XML and renders it as HTML for a browser ("GetXmlData"). Also, there are two versions of each page: a JSP version and an ASPX version. The JSP and ASPX producer and consumers interoperate. They can be mixed and matched so that the JSP consumer can use XML produced by either the JSP or the ASPX producer. Likewise the ASPX consumer can use XML from either the JSP or the ASPX producer.

The Infrastructure Technology

How It Works

The consumer page sends an outbound HTTP GET request to a (potentially remote) "producer" page. The producer queries the database, then generates XML from the result. That XML is returned via HTTP to the consumer. The consumer then renders the XML into HTML, via an XSL Transform.

Generating the XML

In the .NET application, the XmlDataFeed page uses the SqlClient to query SQL Server. It performs 2 queries - one against the order list and a second to retrieve the order detail information. The app fills a single DataSet object with that information, and then generates XML by calling the WriteXml() method on the dataset. It's pretty simple.

The JSP application performs the same SQL queries against the same MSSQL database. In return, the JSP page gets two instances of java.sql.ResultSet. The Java app then loops through the results and produces XML by concatenating strings and angle brackets. This is then printed to the output stream.

The JSP page is about twice as large as the equivalent ASPX page, not counting the extra helper code used in the Java version. This difference is primarily due to the logic associated with generating XML - in ASPX it is simple, and in Java it is a bit more manual.

The dynamically produced XML is the same regardless of the page technology.

XSL Transforms

The rendering step in the consumer is accomplished via an XSL transform, using a single, common xsl file regardless of the page technology. The HTML pages use a common Cascading Stylesheet (CSS) file for formatting.

How It Was Built

I used a text editor to build all of the JSP, ASPX, CSS, and XSL.


Last Updated: Wednesday, 24 March 2004