YOUR FEEDBACK
John Portnov wrote: This code does not work for me. I created a new website and a C# console applic...
AJAXWorld RIA Conference
$300 Savings Expire August 22
Register Today and SAVE!


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TODAY'S TOP SOA & WEBSERVICES LINKS


Perfect Partner for Web Services: Getting to Know XForms
Find out about XForms and why they are the perfect partner for Web Services

XForms events and actions can be combined to do some of the following:

  • Display a message to the user with varying degrees of intrusiveness ranging from modal dialog boxes to fleeting tool tips
  • Change some value in the instance document
  • Dynamically insert or delete line items in tables
  • Navigate to a new URI, possibly in a new window and possibly replacing the active form
  • Submit all or part of an XML instance document
  • Toggle between different component renderings to implement multi-stage forms or tabbed applications
Introduction to Amazon Web Services
To demonstrate some of the features of XForms and how well suited they are to Web services, I've created a simple form (Listing 3) that uses an Amazon.com Web service to provide a simple book search facility.

As some background, Amazon Web services were launched in mid-2002 as a way of allowing their business partners to create their own content-rich applications based on Amazon's product and pricing information and e-commerce model. Amazon now offers a range of Web services, including access to Web site information and traffic history charts (Alexa Web Information Service) and a distributed message queue service (Amazon Simple Queue Service). Check out the Amazon Web service references in the Resources section for details about all of Amazon's Web services.

For the XForms here, I'll be using the primary Amazon E-Commerce Service (ECS), version 4.0. The ECS exposes 18 methods that allow developers to search for Amazon and third-party product and seller information; details about customer content such as reviews, wish lists, and listmania lists; and to manage shopping carts of products for purchase through Amazon. If you would like to implement this XForms, you will need to create a free Amazon Web services account. Besides giving you access to forums, blogs, code samples, and a technical library, you will also receive an Access ID Key, which is a 20-character code that must be included as a parameter for each Web service call to uniquely identify the caller.

While it's free to use the ECS, there is a restriction that requests should be limited to no more than one per second. The licensing agreement gives the fine detail and other restrictions.

Building and Running the Web Service Client
Creating an XForms Web service client involves defining a SOAP payload as the XForms model, populating this via the XForms user interface controls, and then submitting the payload to a Web service endpoint. When the Web service response is received it can be processed using XPath or XSLT.

Listing 3 shows an XForms model that contains a SOAP payload that initiates one of the most common ECS requests, an item search. Besides the mandatory Amazon Access Key ID, nearly all of the parameters for an item search are optional, so only the absolute minimum needs to be submitted. For this particular XForms, users will be able to search Amazon for books based on keyword, author, and title criteria, so these elements are included in the SOAP payload. The SearchIndex element contains a value of Books meaning the search will target only books, but this could easily be broadened to cover all product types. In addition, the results of a search can be sorted according to relevance, price, or title. This sorting happens on Amazon's side before the Web service response is returned, so it's one fewer processing activity for the client. The Availability, Condition, and MerchantID have been pre-filled with values that should return the widest range of search items. Finally, the ResponseGroup indicates what and how much information will be returned. For an item search and a ResponseGroup value of Medium, this will include full product and pricing details, links to images, and editorial reviews.

Figure 2 shows the XHTML document in Listing 3 open in Internet Explorer.

The search criteria entered by the user populates the XForms model (the SOAP payload) by way of XPath expressions in the body of the XHTML document. Following recommended XForms practice, only enough host language markup is used to correctly position the XForms components, and any styling is handled by an external cascading style sheet (Listing 2).

Once the XForms model has been populated, it is be submitted to the ECS endpoint (shown in the submission element) just like any other Web service payload. The submission element wraps around a toggles element, which switches to the response user interface when the Web service response is ready (Figure 3).

Again, XPath is used, this time with output elements, to extract the necessary information from Web service response payload for display to the user. Notice the repeat element in the responseGUI case element: this simply iterates over a homogeneous collection of nodes from the Web service response, in this case creating a table-like display.

The Search Again button then resets the XForms and the search can be performed again.

Conclusion
HTML forms have long been a standard part of Web development, but they are showing their age when confronted with omnipresent XML, the almost irresistible rise of Web services, and more demanding user-interface requirements (Sidebar 2).

The simple Web service client demonstrated here only hints at the advantages XForms offer over HTML forms. In reality, XForms are a powerful tool for building device-independent, declarative, form-based applications that don't need scripting or programming to deliver rich user interfaces. More important, when compared to other ways of creating Web service clients such as using the SOAP APIs, the XForms alternative is concise and comes with a built-in means of getting a window onto the request and response payloads.

Even so, creating XForms is not as simple as defining tags in an XHTML page. The development model provides a sometimes daunting range of possibilities, and until XForms engines are more widely supported, developers need to critically consider how they will deliver XForms functionality to their clients.

Still, the benefits of using XForms more than balance this effort.

References

  • Amazon Web Services: www.amazon.com/gp/aws/landing.html
  • Dubinko, M. XForms Essentials. O'Reilly & Associates, 2003.
  • Halstead, P., Blain, M., and Manava-Teredesai, V. Developing Solutions with Microsoft InfoPath. Microsoft Press, 2005. If you are looking at a range of form-based technologies besides XForms, it might be worth evaluating InfoPath 2003 to see if it fits your requirements.
  • Levitt, J. The Web Developer's Guide to Amazon E-Commerce Service. J9T Publications, 2005. Until recently, Amazon's Web services have been a work-in-progress, with significant changes made between releases. Thus, finding good examples and version-right information has been frustrating. Although written specifically for PHP developers, this book is still a fantastic reference for all developers looking for the fine details of using the Amazon Web services.
  • Musciano, C. and Kennedy, B. HTML and XHTML: The Definitive Guide, 5th edition. O'Reilly & Associates, 2002.
  • Raman, T. V. XForms: XML Powered Web Forms. Addison Wesley Professional. 2003.
  • Simpson, J. E. XPath and XPointer O'Reilly & Associates, 2002.
  • W3C XForms 1.0 (Second Edition) Specification: www.w3.org/TR/2005/PER-xforms-20051006
  • W3C XForms 1.1 Working Draft: www.w3.org/TR/xforms11. Among the features planned for the next XForms version are utility functions for XPath expressions such as the Luhn algorithm for credit card number validation, and better support for interacting with Web services.
  • W3C XML Events Recommendation: www.w3.org/TR/xml-events
  • W3C Document Object Model (DOM) Level 2 Events Specification: www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113
About Craig Caulfield
Craig Caulfield is a senior software engineer for a defense and commercial software house in Perth, Western Australia. He has a Bachelors degree in Computer Science, a Masters degree in Software Engineering, and holds certifications in Java, XML, DB2, UML, MySQL, and WebSphere.

YOUR FEEDBACK
SYS-CON Italy News Desk wrote: HTML forms are one of the best-known techniques for gathering data from a user and submitting that data to a server. However, HTML forms are only simple tools and don't natively support some of the features needed by current Web applications such as sophisticated data validation. Also, the user interface created by HTML forms is essentially hard coded for one device, meaning the same form can't be easily re-tasked for, say, PDAs or mobile phones.
SYS-CON India News Desk wrote: HTML forms are one of the best-known techniques for gathering data from a user and submitting that data to a server. However, HTML forms are only simple tools and don't natively support some of the features needed by current Web applications such as sophisticated data validation. Also, the user interface created by HTML forms is essentially hard coded for one device, meaning the same form can't be easily re-tasked for, say, PDAs or mobile phones.
XML JOURNAL LATEST STORIES . . .
ISO said Friday that the appeals made by Brazil, India, South Africa and Venezuela protesting the standardization of Microsoft’s Office Open XML (OOXML) file format hadn’t gone anywhere – it was unclear whether any of them had any standing anyway – but since they “failed to g...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the 4th Fl...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be...
Since its inception, XML has been criticized for the overhead it introduces into the enterprise infrastructure. Business data encoded in XML takes five to 10 times more bandwidth to transmit in the network and proportionally more disk space to store.
Vordel unveiled version 5.1 of its XML network infrastructure products, to accelerate, manage and protect XML applications. Vordel 5.1 addresses the need for lifecycle management of policy across the SOA. By combining the central management of SOA policies with distributed enforcement ...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS


ADS BY GOOGLE
BREAKING XML NEWS
Avineon, Inc. (http://www.avineon.com), a successful provider of IT, geospatial, engineering and pro...