|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TODAY'S TOP SOA & WEBSERVICES LINKS XML News Desk Perfect Partner for Web Services: Getting to Know XForms
Find out about XForms and why they are the perfect partner for Web Services
By: Craig Caulfield
Mar. 6, 2006 02:45 PM
XForms events and actions can be combined to do some of the following:
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 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 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
YOUR FEEDBACK
XML JOURNAL LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING XML NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||