XML is the most popular choice for exchanging data in a structured and self-describing notation. The W3C suite of XML standards describes a set of specifications that are well accepted in business, governments, science, and other industries. Because XML's direct predecessor SGML has been in use since the 1980s, there is more than 20 years of experience and tools for working with XML.
Various industries utilize XML standards for defining industry-specific formats for standardized information exchange. Furthermore, XML is a popular notation for viewing and manipulating data, for example, through XForms or Lotus Forms. XML and hybrid database systems, such as DB2 pureXML™, provide native XML storage. The latter means that XML is stored as-is without the need to split the information encoded in the elements and attributes of XML into relational tables (also known as "shredding").
Being able to utilize XML and XML-based industry formats allows the creation of applications that utilize an end-to-end XML architecture. One major advantage of end-to-end XML applications is that the same XML-based industry format or custom notation can be used for storing (see the "Data" layer in Figure 1), for exchanging (see the "Information Exchange" layer in Figure 1), and for viewing and manipulating (see the "User Interaction" layer in Figure 1) XML.
Figure 1. End-to-end XML architecture
The goal of this article is to illustrate how to create a functioning application quickly by adopting an end-to-end XML architecture for a specific industry-specific exchange format. The exchange format used as a basis for the work presented is the IRS e-File 1120 format which is an exchange format defined by the United States Department of Treasury for the purpose of reporting taxes (see the Resources). The steps for creating an end-to-end XML application include:
- Creating a DB2 pureXML database capable of storing IRS e-File 1120 XML documents natively
- Exposing the database using the Universal Services for accessing the database through Web services
- Creating a user interface using the XML Forms Generator (XFG) for viewing and manipulating IRS e-File 1120 XML documents
Finally, ideas are given to show how applications utilizing an end-to-end XML architecture may be augmented with additional technology to improve their functionality. Before continuing to read the article, ensure that the software listed in the Requirements section is installed and configured properly.
For experimenting and following these instructions, the software listed below needs to be installed properly.
- IBM DB2 Express-C (FREE): A hybrid database system utilizing the pureXML technology to store XML data natively. For more information, refer to the Resources section of this article.
- IBM Data Studio (Trial): The development environment offering a multitude of functionalities, such as exposing database operations as Web services. IBM Data Studio is also the environment needed to run the XFG. For more information, refer to the Resources section of this article.
- XML Forms Generator (FREE): An Eclipse-based plugin that allows you to generate XForms based on an XML document instance and a Web service Description Language (WSDL) file. To fully utilize the plugin’s capabilities with IBM DB2 pureXML, it must be installed within IBM Data Studio. For more information, refer to the Resources section of this article.
Create the database (DB2 pureXML industry bundle) for storing XML
DB2 pureXML industry bundles contain vertical industry samples of XML documents, links to relevant XML schemas, and sample code to help database administrators, software developers, and architects in vertical industry businesses get started with DB2 9.x pureXML features. An industry bundle is typically created for one specific industry, such as an industry bundle for the Financial products Markup Language (FpML) or the IRS e-File 1120 format.
The industry bundle for the IRS e-File 1120 format is used in this article to create a database and populate the same with sample XML documents, providing the first layer to an end-to-end XML architecture (see Figure 2).
Figure 2. First layer providing native XML storage capabilities
For setting up and populating the DB2 pureXML database, refer to the Set up a sample database section of "Universal Services for pureXML using Data Web Services" (developerWorks, May 2008). If a broader overview on industry bundles is needed, consult "Get started with Industry Formats and Services with pureXML" (alphaWorks, December 2006). (see the Resources section).
The populated database serves as a basis to continue with the next level of development: exposing the database through Web services.
Create the Web services (Universal Services) for exchanging XML
The Universal Services, based on the Data Web Services mechanism, are a fixed set of database operations, including insert, update, delete, and query for accessing the database through simple REST or SOAP requests, as illustrated in Figure 3.
Setting up the Universal Services is achieved through configuring and executing a command line script. Executing the script creates a Web archive (WAR) file that may be deployed to an application server, such as the WebSphere® Application Server or Apache Tomcat.
Figure 3. Second layer exposing the database through Web service operations
The configuration and installation of the Universal Services is not illustrated any further since it is already described in another, accompanying, article. Therefore, refer to the Install the Universal Services section of "Universal Services for pureXML using Data Web Services." If more information on Data Web Services is needed, refer to the Resources section.
Now it is possible to develop a User Interface (UI) accessing the database through simple Web service requests, as illustrated in the following section.
Create the forms (XFG) for viewing and manipulating XML
In the following section, XForms for viewing and manipulating data stored in the database are created, providing the third layer, namely the "User Interaction" layer, illustrated in Figure 4.
Figure 4. Third layer for viewing and manipulating information
The XForms are created utilizing the XFG plugin installed as part of IBM Data Studio. Therefore, a brief introduction to the XFG plugin is provided followed by an illustration that shows how to create XForms using the XFG plugin.
Overview of the XFG
In the following section, an overview of the functionality of the XFG plugin is provided. However, the description contains relevant information for this article only. If a broader and more detailed overview on all the capabilities of XFG is needed, refer to the related series of articles "Integration between XML Forms Generator and Data Studio" found in the Resources section.
For generating fully functional XForms, the XFG plugin bases the generation process on various artifacts, which are: the WSDL file of the Web service to be used, a sample XML document, and optionally the XML schema according to the XML document.
Figure 5. Runtime artifacts used by the XFG plugin
To generate XForms, the XFG plugin at first analyzes the WSDL file describing all the Web service operations available through a particular Web service (see Figure 5, Number 1). After the user chooses one of the available operations, the XFG plugin analyzes the different input parameters of the operation, since for each input parameter an appropriate input field in the forms needs to be generated. The latter is simple for data types, such as integer or characters, but more complex for input parameters of type XML. The generation of the input fields for the XML data type is based on a sample XML document (see Figure 5, Number 2) and optionally also on the backing XML schema (see Figure 5, Number 3) of the XML document used. Therefore, the plugin automatically retrieves a set of sample XML document instances from the database (see Figure 5, Number 2). Out of the sample XML documents retrieved, the user may choose one sample XML document serving as a basis to generate the XForms. If a backing XML schema reference by the XML document is available in the XML Schema Repository (XSR) of DB2, the user may choose to utilize XML schema information in the XForms generation.
The description above may sound like a complex process but is, as illustrated below, a straight-forward task. Before proceeding, ensure that a workspace containing all the artifacts needed by the XFG plugin is available. It is also described in the following section.
Create and prepare the workspace in Data Studio
As mentioned above, one of the artifacts needed by the XFG plugin to generate XForms is the WSDL file describing the Web service to be used. In particular, this means that it is necessary to have a workspace available containing the WSDL of the describing Universal Services. To do so, the Universal Services are typically imported into a new or an existing workspace. Since the Universal Services are pre-configured for a particular sample database, it is also necessary to adjust the services to fit the database details used in the scenario of this article. Before continuing to read the instructions below, note that it is possible to either import and adjust the project as described below or to import a pre-configured project without the need to make any particular adjustments. The latter is recommended.
Option 1: Import original Universal Services data development project
To import and adjust the original data development project of the Universal Services, follow the instructions provided in the Modify the Universal Services section of "Universal Services for pureXML using Data Web Services" (developerWorks, May 2008).
Option 2 (recommended): Import the pre-configured Universal Services data development project
In order to use the pre-configured data development project utilizing the correct database connection details, table names, and database schema name, first locate the archive file universal_services_data_studio_project_irs1120.zip, available in the Download section of this article. To import the archive file, follow the instructions described in the Import Universal Services Data Development Project section of "Universal Services for pureXML using Data Web Services." Note that after importing the archive file, no further adjustments are required.
Use the XFG
This section illustrates how to generate XML forms for the IRS e-File 1120 message format utilizing the XFG. Generating XForms requires Data Studio to be launched using the workspace that contains the Universal Services data development project imported in the previous step. The user of XFG in Data Studio is guided through the generating XForms process by a wizard. All the steps performed through the wizard are described in more detail below.
Step 1: To launch the wizard that guides you through the process of creating XForms, navigate to the WSDL file describing Universal Services in the data project explorer of Data Studio followed by right-clicking the WSDL file. The latter causes a submenu to appear. In the submenu choose Generate XHTML/XForm to launch the wizard, as illustrated in Figure 6.
Figure 6. Launch the wizard
Step 2: As mentioned in previously, the XFG plugin utilizes a sample XML document and a WSDL file to create XForms. To retrieve sample XML documents from the database, the XFG plugin needs user credentials to access the database. Therefore, as shown in Figure 7, a valid username and password need to be provided. Furthermore, the option "Retrieve PureXML instance from Database" needs to be checked to trigger the XFG plugin to actually retrieve samples from the database. Click Next to continue.
Figure 7. Configure database access information
Step 3: After the XFG analyzed the WSDL file and recognized all the operations available, the wizard allows the selection of one of the operations. Since the XForms are used to insert new information into the database, the operation named "insertXML()" is chosen, as illustrated in Figure 8. Click Next to continue.
Figure 8. Choose the Web service operation
Step 4: Since the operation chosen in the previous step contains one input parameter of type XML, the wizard allows you to choose a sample XML document used as a basis to create appropriate input fields and controls. Retrieving sample XML documents is triggered through clicking the button located in the column "Reference Instance" (see Figure 9).
Figure 9. Choose reference sample XML document
A separate window opens showing sample XML documents retrieved from the database. One of the sample XML documents needs to be chosen (see Figure 10). Click OK to proceed.
Figure 10. Choose reference sample XML document
The sample XML document chosen in the previous step is now used as a basis to generate the input fields and controls for the XForms (see Figure 11). Click Next to continue.
Figure 11. Choose reference sample XML document
Step 5: The XFG plugin needs an appropriate file name and location for storing the generated XForms. Therefore, either leave the default settings unmodified (see Figure 12) or choose the customized file name and location. Click Next to proceed.
Figure 12. Choose a file name and location for the XForms
Step 6: To generate fully functional XForms, the XFG plugin allows you to specify the endpoint of the Web service to be used. In the current scenario, the endpoint is the SOAP endpoint of the Universal Services (http://localhost:8080/UniversalServices/services/UniversalServices). To specify the custom endpoint, uncheck Use default submit target. and enter the SOAP endpoint of the Universal Services into the input field named "Use this submit target." (see Figure 13).
Figure 13. Specify the submit target to be used
Step 7: Another artifact used by the XFG plugin is the XML schema associated with the XML document instance. Since an XML schema describing the structure of XML document instances allows you to define mandatory as well as optional elements and attributes, the wizard allows to choose between: generated input fields for all elements and attributes (optional as well as mandatory) or required elements and attributes only. Leave all settings unchanged and click Next to proceed (see Figure 14).
Figure 14. Choose the type of elements and attributes to be generated
Step 8: Also, the XFG plugin allows you to store the XML schema and the sample XML document used as a basis for generating the XForms. Therefore, choose a file name and location for the XML document (see Figure 15) as well as for the XML schema (see Figure 16). In each of the steps, click Next to continue.
Figure 15. Choose the file name and location for the sample XML document
Figure 16. Choose the file name and location for the XML schema
According to the settings chosen throughout the different pages of the wizard, the XForms have been generated (see Figure 17).
Figure 17. Completely generated XForms
Run the application
After completing all three major tasks, it is time to see the generated XForms in action. For rendering XForms properly, Mozilla Firefox is required. In addition, Mozilla Firefox needs the Mozilla XForms plugin installed. Note that not all versions of the Mozilla XForms plugin are compatible with each versions of Mozilla Firefox. The software used in the current scenario is Mozilla Firefox, Version 184.108.40.206 together with the Mozilla XForms plugin, Version 0.8.6ff2. Rendering the XForms may look similar to the XForms illustrated in Figure 18.
Figure 18. XForms rendered in Mozilla Firefox with input data entered
To continue, enter information into the available input fields. Note that two particular input fields, referenced as "P1" and "P2", are two input parameters of the Web service operation that were used to generate the XForms. The input parameter named "P1" is of data type integer, the other input parameter "P2" is of type character. The sample data entered to illustrate the XForms in this scenario is the number "24" for parameter "P1" and the text "data entered through XForms" for the parameter "P2." The two input fields for the parameters "P1" and "P2" are followed by a number of input fields that were created based on the attributes end elements of the sample XML document used to generate the XForms. Sample data may be entered in any of the input fields.
After entering the data needed, scroll all the way down to the end of the forms where the Submit button is located (see Figure 19).
Figure 19. Submit button to invoke the submit function of the XForms
Click Submit to invoke the submit functionality of the XForms, inserting the data entered into the DB2 pureXML database through the Universal Services. Therefore, the response message from the Web service is shown (see Figure 20) indicating a successful insert into the database.
Figure 20. Response from the Web service
To ensure that the new record was inserted into the database, the test page included as part of the Universal Services may be used again. If more information on accessing the test page is needed, refer to the Test the Universal Services section of "Universal Services for pureXML using Data Web Services." The URL to access the Universal Services is typically http://localhost:8080/UniversalServices/wsdl. Note that hostname and port may change due to the local system configuration used.
On the test page, navigate to the operation getXMLDocumentByKey, and enter the identifier of the newly created record (for example, the number "24" entered in the XForms input field "P1"), and click Invoke to invoke the Web service operation.
As a result, the data previously entered into the XForms is shown, as illustrated in Figure 21.
Figure 21. Information previously entered into the XForms
Augment the application
The article has shown the ease, simplicity, and speed of creating an application utilizing an end-to-end XML architecture. The user interface and the Universal Services can then be adjusted in response to feedback. In addition, there are a number of possibilities for extending the application with additional functionality.
One possible extension is the validation of data entered into the XForms. Currently, the XForms generated through the XFG plugin may contain simple validation rules generated based on the metadata of the input parameters of the Web service operation used and based on the XML schema used as a basis to generate the XForms. However, an additional technology to validate XML content is Schematron, which may be used in combination with XForms. An example of how to incorporate Schematron validation rules into XForms can be found in the article "Apply Schematron constraints to XForms documents automatically" (developerWorks, June 2006).
Another option, most likely appropriate in a more complex application, is to offload structure and content validation to an external device, such as the IBM WebSphere DataPower SOA appliance. The latter is an XML-processing hardware offering a number of functionalities, such as XML schema validation and Schematron validation. An example scenario is to submit the data entered into the XForms to the IBM WebSphere DataPower SOA appliance which, if validation succeeds, forwards the data to the Universal Services to finally insert the data into the database. Otherwise, the data should be rejected. To see an actual example how the appliance may be used in the context of the Universal Services, refer to "WebSphere DataPower and DB2 pureXML, Part 1" (developerWorks, May 2008) and "WebSphere DataPower and DB2 pureXML, Part 2" (developerWorks, June 2008).
This article has shown that, with fairly small effort, it is possible to create a fully functional application utilizing an end-to-end XML architecture. Creating the application consists, as illustrated in the article, of three basic steps where each of the steps is supported through already available artifacts.
One of the major advantages of creating an application utilizing XML in all levels of the application architecture is to avoid the need to transform data from one format to another. In fact, the same format of information may be used to store information, exchange information, and view and manipulate information.
It is hoped that the article helps you to kick-start projects taking full advantage of an end-to-end XML architecture.
|Universal Services data development project||universal_services_data_development_project_irs1120.zip||204KB|
- Industry Formats and Services with pureXML: Download a great variety of examples, for free! Each example illustrates how to work with XML-based Industry Formats and pureXML. The examples show how to register an XML Schema, how to perform validation of XML instance documents, how to query XML data using XQuery or SQL/XML and much more.
- W3C XForms: Find links to the official XForms specification, as well as to a variety of XForms rendering options.
- W3C site: Find out more about XHTML, Cascading Style Sheets (CSS), XML, XML Events, XPath, and other related standards.
- Internal Revenue Service - United States Department of the Treasury: Get information on the Internal Revenue Service (IRS), forms to file different reports, and electronic versions of these forms, called e-File forms.
- "Generate Web Services for DB2 9 pureXML" (developerWorks, June 2007): Create Web services to insert and retrieve XML data into and from a DB2 9 pureXML database.
- "Exposing DB2 Version 9 pureXML using WebSphere Integration Developer" (developerWorks, September 2007): Build a client to access the Universal Services.
- "IBM Data Studio: Get Started with Data Web Services" (developerWorks, November 2007): Provides a very detailed and simple introduction on how to develop your first Data Web Service.
- "Data Web Services: Build Web Services the new way to access IBM database servers" (developerWorks, December 2007): Create and customize a Data Web Service. Useful theoretical background on Data Web Services is provided, which includes an architectural overview on Data Web Services. The article addresses different aspects of Data Web Services, such as Security.
- Schematron: Schematron is a language for making assertions about patterns found in XML documents and can therefore be used to validate the content of XML documents.
- IBM WebShpere DataPower SOA Appliance: Get an overview on the IBM DataPower SOA appliances product line.
- developerWorks Information Management zone: Learn more about DB2. Find technical documentation, how-to articles, education, downloads, product information, and more.
- Stay current with developerWorks technical events and webcasts.
Get products and technologies
- IBM Data Studio: Download the development environment used to develop Data Web Services, for free.
- DB2 Express-C: Download the free version of DB2, which includes the core functionality as the other data servers, such as the pureXML technology. DB2 Express-C is free to develop, deploy, and distribute.
- XML Forms Generator: Create functional, standards-compliant forms with a click of the mouse using this Eclipse-based tool from alphaWorks.
- Mozilla XForms: Render your standards-compliant forms in Mozilla Firefox using this plugin.
- FormsPlayer: Find a plug-in for Internet Explorer that renders XForms.
- Visual XForms Designer: Check out the home page, with links to installation instructions, prerequisites, and the forum.
- Compound XML Document Toolkit: Explore other open-standard XML markups, including Scalable Vector Graphics (SVG), MathML, VoiceXML, and Synchronized Multimedia Integration Language (SMIL).
- Build your next development project with IBM trial software, available for download directly from developerWorks.
Dig deeper into Information management on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.