Java IoT Authors: Zakia Bouachraoui, Elizabeth White, Pat Romanski, Yeshim Deniz, Liz McMillan

Related Topics: Java IoT

Java IoT: Article

Java and XML in the World of E-Commerce

Java and XML in the World of E-Commerce

In last month's e-Java we discussed the technologies and APIs offered by the Java platform that play specific roles in e-commerce solutions for the enterprise. We also took a high-level glance at how they fit in an n-tier commerce application. Java provides substantial support for e-commerce­based applications; however, Java alone doesn't provide an end-to-end solution for e-commerce­based businesses. Components of the Java platform integrate with complementary technologies to offer complete Internet commerce solutions.

Nowadays the acronym "XML" is found lurking in almost any literature or site that mentions e-commerce. Some consider XML (Extensible Markup Language) to be the enabling technology that will allow the World Wide Web to become a breeding ground for open commerce-based applications. XML helps expand existing technologies into new dimensions of document publishing and content management, addressing the needs of a distributed Web-based environment.

The Java platform and XML are complementary technologies that together can provide a solid foundation for commerce-based transactions across the Internet. This month in e-Java we'll look at how Java and XML can work in the world of e-commerce. Please note that this article doesn't focus on XML itself (although a brief discussion is provided in the next section) or on Java, but rather on how the two technologies provide such a powerful combination for enabling e-commerce applications.

Data Content, EDI and XML
The premise behind Internet commerce is that business transactions can be conducted efficiently and safely over different tiers of the Internet. The evolution of client/server architectures, which are an integral concept behind the Internet, has seen a migration from two-tier architectures to multitier distributed architectures. This places greater demand on the safe and correct passage of electronic data from an Internet source to the corresponding destination. The whole purpose of such commerce transactions is to transfer data content between the two parties participating in the trade.

EDI (Electronic Data Interchange) has been the enabler for electronic transactions for several years now. EDI is a process for exchanging data in an electronic format between heterogeneous applications and/or platforms in an automated fashion, i.e., without manual intervention. However, when applied to an Internet environment, it falls short on several accounts, some of which are:

  • Scalability across multiple tiers of the Internet
  • Lack of support for dynamic data content definition
  • Slow adoption to standards
  • Lack of flexibility in defining business rules
    XML leverages EDI technology and adds the necessary pieces to migrate it to an Internet environment. It does so by adding the following:
  • Ability to separate the data and structure (electronic content) from the processes
  • Ubiquitous interconnectivity between trading entities (this isn't directly provided by XML, but rather by the Internet)
  • Support for dynamic data format definitions
  • Middle-tier storage for caching data
  • Widely accepted standards governed by the W3C (World Wide Web Consortium)

    HTML and XML
    HTML is a presentation markup language that offers a standard format for displaying data in a Web browser. While it provides a standard format for displaying data, the focus is on the visual presentation of data and not on sophisticated data types, as required by e-commerce applications. XML, on the other hand, focuses on data content and provides a clear separation between content and visual presentation. It does this by allowing the applications to define tags that describe the data they're exchanging across the Internet. XML allows the tag information to be embedded in the document itself, so that the document is "self-describing." XML standards allow business partners to define their own self-describing markup languages for supporting electronic commerce.

    Both HTML and XML are derivatives of SGML (Standard Generalized Markup Language). However, while HTML is an implementation of SGML for visual presentation, XML is a subset of SGML used for writing markup languages that specify the format for expressing data content. Figure 1 shows the relationship between HTML, SGML and XML.

    XML + Java = Portable Objects
    So how does all this relate to Java? Well, there are two main aspects of an Internet commerce application. We've taken a look at the first ­ data format and content. XML enables electronic data to be represented in a platform and language-independent manner. This data can be available across several different enterprise domains. However, data by itself doesn't do anything. It needs to be processed by applications. For XML data to be used in a platform-independent manner across the Internet, it needs a hardware-independent environment. The Java platform provides such an environment by offering a distributed, homogeneous computing architecture that resides on the different tiers of the Internet. Java "Internet-enables" XML documents by adding networking and cross-tier transportation capabilities.

    Java and XML together address the issue of portability in e-commerce, an issue that's crucial for successful implementation of Internet-enabled commerce applications. XML provides data that's portable across different application domains. It does so by representing data in a common, well-known format. Java provides code that's portable across different hardware and operating systems. The code adds the functionality for processing and manipulating the data. A natural consequence of this alliance is highly robust, componentized and maintainable applications.

    The synergy between XML documents and Java code is due to the fact that the data encapsulated by XML tags can be easily expressed as Java objects and vice versa. The entities that take part in an e-commerce application are defined in an object-oriented manner as "data objects." This gives rise to "objects" that are portable across the different tiers of a distributed application. You can almost look at these as "portable objects" that morph into XML elements (defined by tags) when they need to be transported between hosts. They morph back into Java objects when they need to be processed or manipulated.

    In other words, working between XML and Java involves the following steps:

  • Constructing a Java object model from an XML document by creating Java objects from XML tags.
  • Using the Java object model to process the data. This should focus on computation-intensive tasks that need to be performed on the data to support the overall business transaction.
  • Generating an XML document from the Java object model by converting the Java objects to the corresponding XML data tags.

    The transformations between XML and Java are illustrated in Figure 2.

    DOM and SAX
    An XML document has to be processed in order to be used. This requires an XML processor that can:

  • Parse XML documents ­ an XML parser
  • Create XML documents ­ an XML editor
  • Provide an API to access the parts of an XML document

    The parsers and editors may be written in Java, which makes them portable across various platforms. The real key to the XML­Java interoperability, however, is the APIs used to access the elements of an XML document. An additional advantage Java brings to XML parsers and interpreters is allowing the XML interface with the Java data processing application to be accessible via different Java components ­ server-side Java Servlets, client-side Applets, middle-tier EJBs or JavaBeans in an IDE. Java also adds its robust security services to the mix. As mentioned earlier, Java components reside in different tiers of a distributed application.

    The XML APIs are of two types:
    1. Document Object Model (DOM): DOM is a platform-independent, language-neutral, tree-based API. It compiles an XML document into an internal tree structure and allows an application to navigate that tree based on the API it exposes. One of the specifications of the DOM interface is in Java (the others are in OMG IDL and ECMAScript). The Java API for DOM is known as Java Language Binding and describes the Java DOM interface.
    2. Simple API for XML (SAX): SAX is a simple, event-based API for XML parsers. SAX doesn't require the creation of an internal tree structure to represent the complete parsed XML document. Instead, when parsing an XML document, it provides events that indicate the detection of the following: start/end of the document, Document Type Declaration (DTD), start/end of elements, element attributes, character data, unparsed entities, processing instructions and more. SAX provides a Java interface that allows any Java application to access any XML parser as long as the parser has a SAX driver.

    Publishing XML
    In a transaction, XML may be used to transport data between the two partners. The data that's obtained at one end of the transaction may be processed but need not be displayed in a UI (indeed, that's the advantage of separating content from presentation).

    On the other hand, one of the desirable features of Web-enabled data is the ability to view the data in a Web browser. Such data may be in the form of a catalog, a quote request/response, etc. In a simple client/server scenario, there are several ways of rendering XML data in a browser:

  • Process XML into HTML on the server and send to the client browser.
  • Process XML into HTML directly on the client and display on the browser.
  • Display the XML document directly.

    Of these three, the third mechanism makes use of XSL (Extensible Style Language). The other two can be achieved by Java platform components. Java Servlets can be used to process XML on the server and send the output to the client as plain HTML. XML-aware Java Applets can be used to process XML on the client. The applet can bind the required parts of the XML document into particular HTML components for display. Browsers like Microsoft's IE 4.0 support this functionality.

    These two mechanisms for rendering XML in a Web browser are illustrated in Figure 3.

    Role of XML and Java in Enterprise Application Integration
    This is the year in which the Java platform APIs are really making their mark in integrating enterprise applications. Although the definition of Java's Enterprise APIs has been there for a while, they're only now achieving a level of maturity that makes them suitable in real-world enterprises. EAI is the mechanism for integrating several disjointed applications to provide a common application interface. XML allows Java objects to be represented as data that moves across middleware tiers that may not be Java-based.

    XML/EDI DataBots
    Remember that XML transports data content, not behavior. The XML/EDI initiative is based on the concept of active objects that have inherent processes associated with them. These are defined by rule templates that can be supplemented by XML/EDI data manipulation agents (DataBots) to ensure that users can express their requirements in high-level, natural language. Currently, the ECMAScript subset of the Java programming language provides the vehicle that permits the DataBots to be deployed and received along with XML/EDI messages.

    Trading Places
    Java and XML complement each other in facilitating Internet-based e-commerce applications. However, the compatibility between such technologies, their common environments and their complementary role in designing e-commerce applications is largely because they've found a common home in the Internet. In other words, the Internet is the environment that has created the need for, and promoted the wide acceptance of, enabling technologies like Java and XML in the world of e-commerce.

  • More Stories By Ajit Sagar

    Ajit Sagar is Associate VP, Digital Transformation Practice at Infosys Limited. A seasoned IT executive with 20+ years experience across various facts of the industry including consulting, business development, architecture and design he is architecture consulting and delivery lead for Infosys's Digital Transformation practice. He was also the Founding Editor of XML Journal and Chief Editor of Java Developer's Journal.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

    IoT & Smart Cities Stories
    In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
    Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
    Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
    Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
    Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
    René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
    Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
    Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
    If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
    Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...