Metadata and Electronic Document Management for Electronic Commerce

Web Services Demonstration

Tom Worthington

Version of 2 August 2008

This item on "Web Services Demonstration" is part of the segment on "Metadata and Electronic Document Management for Electronic Commerce" first presented for the Australian National University course "Information Technology in Electronic Commerce" (COMP3410/COMP6341).

This document is intended to provide both for live group presentation and accompanying lecture notes for individual use. The Slides and these notes are provided in the one HTML document, using HTML Slidy.

Web Services Demonstration

Web services can be thought of as the transaction processing equivalent of the world wide web. The web provided a relatively easy and standardized way to create distributed hypertext. Web Services is a set of standards which aims to provide easy and standardized distributed transaction processing.

This is a demonstration of web services using Amazon.com's implementation.

Just as the web trades off functionality and efficiency for ease of use, so does web services. It is not yet clear if this is a tradeoff which applications developers are willing to make. Applications like the simple one show below are easy to produce, but how much harder will more complex applications be?

Simple Web Services Query

Search for books with "tom" and "worthington"

http://xml.amazon.com/onca/xml3?locale=us& amp;t=universalservice&dev-t=D1XUYSABAOWG8G&
KeywordSearch=tom%20worthington&mode=books&
sort=+pmrank&offer=All&type=lite&page=1&f=xml

In this example a request is made via HTTP to the Amazon.com database, for books with the keywords "tom worthington".

What the request contains

Request Description
http: Address of the service: xml.amazon.com/onca/xml3
dev-t= Identifier of business partner
KeywordSearch= Search for "tom" and "Worthington"
mode=books Search for books.
type=lite Use the lite transaction type
page=1 Display the first set of records (by default 10)
f=xml Return the results in XML format

Results in XML

<Asin>0759614245</Asin>
<ProductName>Universal Service: Telecommunications Policy
and People With Disabilities</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Michael J. Bourk</Author>
<Author>Tom Worthington</Author>
</Authors>
<ReleaseDate>January, 2001</ReleaseDate>
<Manufacturer>1stBooks Library</Manufacturer>
<ImageUrlSmall>http://images.amazon.com/images/
P/0759614245.01.THUMBZZZ.jpg
</ImageUrlSmall>

The result is an XML document, containing data from the Amazon.com database. This is formatted in XML. A sample of the output is available.

This data can then be used as input to another transaction.

Web Services Metadata

Amazon provide the choice of two subsets of data ("lite" and "heavy"), with the >metadata in two formats: DTD and XML Schema.

A SOAP interface is also supplied. This provides a set of operations, including "KeywordSearchRequest", but is not used for this demonstration.

Metadata as a DTD

<?xml version="1.0" encoding="UTF-8"?> ...
<!-- ...................................................................... -->
<!-- File: developer-lite.dtd -->
<!-- ...................................................................... -->
<!-- DTD for developer.amazon.com xml -->
<!ELEMENT ProductInfo (Details*, ShoppingCart?, ErrorMsg?)>
<!ATTLIST Details url CDATA #REQUIRED >
<!-- url is the url of the product page -->
<!ELEMENT Artist (#PCDATA)>
<!ELEMENT Artists (Artist+)>...

The DTDs and XML Schemas represent the same metadata in different formats.

Metadata as XML Schema

<?xml version="1.0" encoding="UTF-8" ?> -
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="Actor" type="xs:string" /> <xs:element name="Artist" type="xs:string" />
- <xs:element name="Artists">
- <xs:complexType> - <xs:sequence>
<xs:element ref="Artist" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
...

The XML Schema is easier to use in an automated system.

XML to HTML transformation

http://xml.amazon.com/onca/xml3?locale=us&t=universalservice&dev-t=D1XUYSABAOWG8G&
KeywordSearch=tom%20worthington&
mode=books&sort=+pmrank&offer=All&
type=lite&page=1&
f=http://www.tomw.net.au/2002/ws/simple.xsl

The XML produced from the Amazon.com database is intended as input to another system, rather than being displayed directly. To make it easier to display on a conventional (HTML) web page, Amazon provide a process for transforming the XML output into HTML, using a XSL style sheet supplied as part of the request. The only change to the query is to replace the "xml" of the format ("f=xml") with the specific address of the XSL transformation document.

This example XML to HTML transformation is based on one provided by Amazon and produces a web page.

Creation of HTML by XSLT

<title>Some Books From Amazon.com</title>.

...

<xsl:template match="Details">
<p>
<a href="http://www.amazon.com/exec/obidos/ASIN/{Asin}/universalservice">
<img src="{ImageUrlMedium}" width="107" height="140" align="left" alt=""/>
<xsl:value-of select="ProductName"/></a>

...

The XSLT creates some static HTML, such as the document title.

For each book found, it extracts details, such as the product identifier (Asin), URL of an image of the product (ImageUrlMedium) and ProductName.

Data values are substituted

<a href="http://www.amazon.com/exec/obidos/ASIN/0759614245/universalservice"><img src="http://images.amazon.com/images/P/0759614245.01.MZZZZZZZ.jpg" width="107" height="140" align="left" alt="">Universal Service: Telecommunications Policy and People With Disabilities</a>,

The data values are substituted into the HTML template to produce a web document.

Values substituted

In this case:

Field Value
Asin 0759614245
ImageUrlMedium http://images.amazon.com/images/P/0759614245.01.MZZZZZZZ.jpg
ProductName Universal Service: Telecommunications Policy and People With Disabilities

Web browser renders HTML with images

Universal Service: Telecommunications Policy and People With Disabilities,

When rendered by a web browser, the HTML will produce an image of the cover of the book, the book title, with a hypertext link to the item on the Amazon web site.

Some points to note

Acknowledgements

Thanks to Steve Jenkin and Frank van Praag for getting the XSL to work.



© Tomw Communciations Pty Ltd 2006 - 2008

Creative Commons License
Metadata and Electronic Document Management for Electronic Commerce by Tom Worthington is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 Australia License.

Web page by