HomeDigital EditionSys-Con RadioSearch Web Services Cd
B2B Beginning WS Business Process Management Case Studies Content Management Distributing Computing e-Business Electronic Data Interchange Enterprise Industry Insight Integration Interviews Java & Web Services .NET Portal Product Reviews Scalability & Performance Security SOAP Source Code UDDI Wireless WS Standards WS Tips & Techniques WSDL WS Editorials XML

Source Code for this article

Web Services has been touted as the next big achievement that may eventually replace our current model for building e-business applications. Although it's true that Web services presents tremendous opportunities, it is also true that Web services is an extension of traditional environments and tools, and will still require the fundamentals that govern the use of current environments and tools.

The power of Web services is its reliance on simplicity, a foundation in current Internet technologies, and a focus on standards, including XML for data, SOAP for transport, WSDL for location, and UDDI for directories. Web services applications, like all applications, require a development environment and language with a solid deployment infrastructure, including the ability to connect and integrate existing resources, such as data and processes, as well as develop new ones.

For the purpose of this article, we'll focus on the role of data and XML within Web services as a critical component of the architecture. We'll discuss topics that organizations should consider as they approach data and database utilization with XML and Web services. Assessing the state of the industry in terms of the role of data and XML leads to three interesting topics that we will explore: a database-centric approach, a development platform approach, and the emerging APIs and components.

Database-Centric Approach
Many organizations will approach Web services starting with core assets that already reside within the business - data and processes. For XML Web services and databases, the market has consolidated into two primary categories that could be termed "RDBMS with XML" and "Native XML Database." Leading RDBMS vendors, such as IBM (DB2), Microsoft (SQLServer), and Oracle (Oracle9i), have implemented various elements of XML support by extending their products. A few vendors, such as Software AG, eXcelon, and Ipedo, have delivered completely new databases built from the ground up for XML.

From the RDBMS vendor perspective, there are three typical implementation considerations for XML and Web services:

  • Data types: The ability to store XML documents in the database (typically using a data type similar to a LONG VARCHAR or CLOB)
  • Mapping: Access and mapping between hierarchical XML and rectangular data stored in traditional relational database rows and columns
  • Processing: External processes and extensions to stored-procedure grammar and functionality to enable processing of XML.

    Let's explore the individual database capabilities with the summary overview provided in Table 1.

    Table 1

    IBM DB2
    With DB2 and IBM DB2 XML Extender, IBM's approach to XML and Web services includes XML documents in the database with new XMLVARCHAR and XMLCLOB types, XML collections for XML-to-relational data mapping, and a combination of stored procedures, triggers, and user-defined functions (UDFs) for XML processing. DB2 XML Extender leverages document access definition (DAD) files for the schemas that map the hierarchical structure of XML documents to the actual relational structure in the database. In addition, DB2 can be used to create Web services that are defined by SQL statements or by a DB2 XML Extender DAD file enabled through IBM's document access definition extension (DADX). DADX files also manage database connection information using JDBC and JNDI and related XML schema, SOAP, and WSDL information for developing and deploying Web services. DB2 data is accessible through a variety of interfaces including Java, JDBC, and SOAP. www-3.ibm.com/software/data/db2/extenders/xmlext/index.html)

    Microsoft SQL Server
    Microsoft's SQL Server includes the Microsoft XML SQL package and the new SQL Server Web Services Toolkit. These enable XML-to-relational data mapping and direct Web services support from the database, but Microsoft does not provide direct facilities for storing, indexing, and searching native XML documents in the database. The XML Views facility enables developers to work with SQL Server data through XPath and XQuery with XDR XML Schemas and XSD Schemas as if the database were an XML file. The OpenXML object and the new "... for XML" Transact-SQL grammar enable SQL-to-XML processing.

    For direct mapping via XML documents to perform updates, inserts, and deletions to a database, Microsoft also includes Updategrams. The SQL Server Web Services Toolkit creates XML Web services from SQL Server stored procedures or server-side XML templates via SOAP. SQL Server data is accessible through a variety of interfaces for building Web services including HTTP via XPath and XQuery, direct SOAP support, and ADO.NET for .NET Framework developers. (See www.microsoft.com/sql/techinfo/xml/default.asp)

    Oracle9i
    Oracle has implemented support with Oracle9i and the Oracle XML Developer Toolkits (XDKs), enabling storage and manipulation of XML documents in databases via the new XMLType, XML to relational mapping, and new PL/SQL procedures for XML processing. PL/SQL package extensions for SQL-to-XML processing include DBMS_XMLGEN (for queries to XML) and SYS_XMLGEN (for query arguments to XML). The XML SQL utility generates Java XML documents, DTDs, and schemas from SQL queries. The XSQL Servlet combines XML, SQL, and XSLT in the server at runtime to deliver dynamic Web content. For Web services, SOAP-based interfaces are provided through Oracle SOAP. Oracle XDKs are available for a variety of development environments, including Java, C/C++, and PL/ SQL, with access interfaces including Oracle OCI extensions, HTTP XPath, SOAP, and JDBC. (See http://otn.oracle.com/tech/xml/xdkhome.html)

    Native XML Databases
    Native XML databases focus on storing and processing XML data and documents natively - storing, reading, writing, and maintaining data and documents in a native XML format. Most XML databases provide their own proprietary tools and interfaces for accessing and manipulating their systems as well as standard interfaces and technologies such as HTTP XPath/XQuery, SOAP, ODBC, JDBC, and more. One advantage of native XML databases is that developers can interoperate exclusively in the XML domain and leverage the latest XML features and optimizations, although these systems may not have all the "burned in" enterprise features of relational databases. Most XML databases include tools for integrating, or migrating, and other types of data such as relational data. Vendors in this category include SoftwareAG, eXcelon, and Ipedo. (See www.softwareag.com/tamino, www.exceloncorp.com/platform/extinfserver.shtml, www.ipedo.com/html/products_xml_dat.html)

    Development Platform Approach
    While some organizations will focus on XML and Web services using the data-centric database approach, others will focus on XML and Web services using a development platform approach. Because XML and Web services are all about standardization and interoperability, it's important to look to standards-based techniques for data connectivity. From this perspective, the de facto or emerging standards for data connectivity that play a role in XML and Web services include 3GL/4GL environments, Microsoft .NET, and J2EE.

    A significant shift is occurring in data connectivity as we move from traditional 3GL/4GL client/server and Web application environments to distributed applications and Web services. Traditional client/server and Web application-environments relied on connection-based synchronous communication with the back-end database. Although this means tight control over locking and transaction behavior, it also can raise some potential performance and scalability issues when you consider the thousands of possible users and transactions that are concurrently updating data across the Web. As a result, Microsoft, with ADO.NET, and the Java community, with WebRowsets, are focusing on XML and improved scalability with XML rowset-type architecture that is fundamentally disconnected and asynchronous in nature. This issue is mentioned here because developers and software vendors must recognize the new paradigm and adjust appropriately.

    3GL/4GL Environments
    Although there is tremendous excitement around Java and emerging Microsoft .NET technologies, studies indicate that over half the application development activities around the world still involve traditional 3GL and 4GL environments, from C/C++ to Visual Basic. Given the tremendous investment in technologies and skills, many organizations want to leverage these resources while tapping into the new opportunities that XML and Web services offer.

    For data connectivity in these environments, the dominant standard is Open Database Connectivity (ODBC). ODBC is a mature, proven standard for interoperability that is available across all major operating systems and development environments accessing hundreds of different data stores. However, it is not widely known that ODBC includes XML capabilities, and these capabilities can be leveraged to assemble Web services as shown in Figure 1.

    Figure 1

    ODBC drivers that provide full ANSI SQL-based read-and-write capabilities across XML files are available. Developers can code in the ODBC API they know and manipulate XML using traditional SQL methods and rectangular data formats. They can query XML documents using SQL SELECT, create XML documents using SQL CREATE TABLE, and update XML documents using SQL UPDATE. Developers can also persist the results from an SQL query into an XML document for posting on the Web or to use within a Web services component. These technologies leverage standard XML DTDs and DOM parsers. The code fragment in Listing 1 shows an example of selecting data from an XML file Inventory, XML using SQL and relational methods, and persisting SQL data from Oracle into an XML file called Parts. XML. (See www.datadirect-technologies.com/tech_library/ddlibrary.asp)

    J2EE Platform
    Standardized data connectivity has been a key part of the Java platform from the early development of Java through the Java Database Connectivity (JDBC) specification. JDBC 3.0 delivers developer productivity enhancements with fine-tuning capabilities, as well as new XML support. With this version, the Java Community is extending the platform with initial work on WebRowsets for XML. WebRowsets are components that exist on top of a JDBC driver to enable the developer to use data in an XML format and a disconnected state (see Figure 2). WebRowsets are in further development under JSR 114 with advancements expected later this year.

    Figure 2

    Disconnected WebRowsets are rows of tabular data cached in memory that are updatable and serializable to XML. WebRowsets are in memory caches of XML data, currently implemented for tabular or rectangular data, with semi-structured hierarchical data likely to follow. Objects called Writers are available to propagate changes back to the underlying database. Because of the disconnected model, WebRowset uses optimistic concurrency. WebRowsets can be operated upon by standard XML technologies including JDOM. Listing 2 shows an example of using a relational database table inventory as an XML WebRowset.

    With WebRowsets, the Java strategy has been to focus on simplicity and portability of data with XML at the expense of some finer control, such as using primary/foreign keys. In the end, for building XML Web services components and applications in Java, developers can leverage JDBC for direct connectivity to a wide variety of back-end data stores through relational structures and SQL grammar, or they can use WebRowsets to share data in XML format under a disconnected model. (See http://developer.java.sun.com/developer, www.datadirect-technologies.com/tech_library/ddlibrary.asp)

    Microsoft .NET Platform
    With the key focus on XML Web services, Microsoft has fundamentally changed their approach for accessing data to the disconnected model by revamping their development platform with Visual Studio .NET and revised ADO technology to create ADO.NET. From the data access and database perspective for the .NET Framework, Microsoft provides facilities to manipulate data as a tabular rowset or a hier0archical XML document (see Figure 3).

    Figure 3

    Microsoft has replaced the connected RecordSet object with a new set of objects led by DataSets. DataSets are essentially in-memory caches of database data in XML format running in a disconnected model using optimistic concurrency. DataSets contain collections of DataTables that are populated from back-end databases accessed via ADO.NET Managed Providers. ADO.NET includes a series of additional objects and methods for manipulating XML data including create, query, and update. Microsoft provides the capability to manipulate the data from an XML approach using XPath, XQuery and so on, as well as tabular data oriented approaches with DataReaders and DataAdapters. Listing 3 shows an example of using a relational database table Inventory as an XML WebRowset.

    With ADO.NET, Microsoft's strategy has been to focus on database functionality and a broad programming model, at the expense of database neutrality where key functions, like database metadata and standardized parameter markers, are not exposed. In the end, for building XML web services components and applications with .NET, developers can focus on developing XML applications in a variety of languages using XML methods or database-oriented methods for data manipulation. (See www.microsoft.com/sql/techinfo/xml/adonetprimer.asp,www.datadirect-technologies.com/tech_library/ddlibrary.asp)

    Emerging APIs and Components
    As we've explored database-centric and API-centric approaches, one thing is clear - there are many ways to use data with XML to build Web services (see Figure 4). This makes you realize the need for a more consistent approach to building applications and Web services that use XML and database data.

    Figure 4

    In fact, there are emerging technologies that take the combined elements of the other approaches to enable easier interoperability between existing relational data and XML formats regardless of the backend data store (see Table 2).

    Table 2

    These software components and tools, for example, use SQL, XML, and environments such as Java to help developers build applications that insulate them from all the variations of database and XML implementations. Interfaces provide traditional SQL grammar extended with key XML constructs to enable the application to seamlessly move between XML and SQL database formats. The opportunity for success lies in their independence of database or platform combined with leveraging other standards including DOM, SAX, JDOM, W3C schemas, DTDs, XPath, XQuery, JDBC, ODBC, and so on. Developers choose technologies like Java and XML for portability, but quickly find that the XML-to-database portability goes only so far. Vendors focusing on emerging technology here include RogueWave Software and DataDirect Technologies. (See www.datadirect-technologies.com/jdbc/ connectjdbc/jpxconnectjdzbc.asp.)

    Conclusion
    Although some organization may have a utopian view - where all Web services data resides in XML - the reality is that trillions of bytes of corporate data are stored in existing relational and legacy databases and will continue to reside there. XML will likely become the common integrating medium for Web services applications, providing a de facto standard to transmit corporate data. Ultimately, data will typically start and end in a relational or legacy database. As we've seen, developers have a variety of interfaces and tools at their disposal to interoperate between database data and XML data and build new types of applications and Web services. The industry will evolve and consolidate around a handful of them.

    Author Bio
    Brian C. Reed is vice president of business development and strategic planning at DataDirect Technologies, a leading supplier of components for connecting data and applications across diverse environments such as Java, .NET, and legacy, where he leads their business strategy and growth efforts. Brian has been involved with information, databases and connectivity standards such as JDBC, ODBC, ADO, and XML since their inceptions and has more than 10 years of experience in standards-based data connectivity and integration. brian.reed@datadirect-technologies.com

    Data - A Key Part of Web Services, by Brian C. Reed
    WSJ Vol 02 Issue 05 - pg.13

    	
    
    
    Listing 1
    
    // Sample SQL SELECT of XML data
    // Inventory.XML is the XML file containing 
    // well-formed hierarchical XML data
    SQLDriverConnect (hdbc, DSN="XMLDataSource"...)
    SQLExecDirect (hstmt, "Select * from Inventory", 
    SQL_NTS) 
    
    // Sample SQL SELECT with relational to XML persistence
    // Parts is the relational table of parts information 
    // that will be persisted into XML file
    SQLDriverConnect (hdbc, DSN="OracleDataSource"...)
    SQLExecDirect (hstmt, "Select * from Parts", SQL_NTS) 
    SQLSetStmtAttr  (hstmt, SQL_PERSIST_AS_XML,  
    "//myweb/inventorylist/parts.xml", SQL_NTS)
    
    Listing 2
    
    // Connect and execute statement
    stmt = conn. createStatement();
    rs = stmt. executeQuery(" select * from inventory");
    
    // Create and populate the WebRowSet
    WebRowSet wrs = new WebRowSet();
    wrs. populate(rs);
    
    // close the connection
    conn. close();
    
    // Iterate through WebRowSet that contains values...
    wrs. next();
    
    // write the RowSet out as XML
    wrs. writeXML( out);
    
    Listing 3
    
    //Create statement
    SqlCommand command = new SqlCommand();
    command.CommandType = System.Data.CommandType.Text;
    command.CommandText = "select * from inventory";
    command.Connection = con;
    
    //Populate DataSet with results of select
    DataSet dsInventory = new DataSet();
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = command;
    adapter.Fill(dsInventory,"Inventory");
    
    //Get DataTable from DataSet
    DataTable myDt = dsInventory.Tables[0];
    
    // Iterate for each row
    foreach (DataRow r in myDt.Rows)
      ...
    
    //Write DataSet as XML
    dsInventory.WriteXml(writer);
    
    
    

    All Rights Reserved
    Copyright ©  2004 SYS-CON Media, Inc.

      E-mail: info@sys-con.com

    Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.