|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TODAY'S TOP SOA & WEBSERVICES LINKS Java And XML The New Requirements of Internet Business Architecture
The New Requirements of Internet Business Architecture
Aug. 18, 2000 12:00 AM
The drive has begun for a new generation of Internet commerce architectures. The stimulus is coming from organizations building customer-oriented e-tail sites and business-to-business applications. New architectures are needed to accommodate both sets of requirements. Java's move into enterprise software development is also a major step toward the development of these new applications. With the XML revolution, major vendors and organizations have agreed on XML as the standard for information exchange. This standardization also requires a change in the way we develop Java-based Web applications. Java Servlets, the part of enterprise Java responsible for interacting with HTTP requests, should be able to communicate with any type of delivery channel such as a customer browser, a PDA/mobile phone or another Web server. With XML as an intermediate format, you can take data from any source and deliver it to any device. Suppose you have a Web application that provides an online pizza inquiry and order service. You want to deliver this service to a mobile phone, PDA and/or Web browser. Another supplier - a business partner - may be required (order distribution to multiple suppliers) to make specialized pizzas. Since each client device has specific formatting requirements, the same data can't be sent to everyone. The mobile can understand only WML; the browser can render only HTML; and the business partner's Web server requires plain XML data. If you're developing separate servlet (Web application) versions for each delivery channel or using DCOM/CORBA to integrate the different supplier networks, then your architecture needs a major change - XML over the Internet. XML has gained widespread popularity as a way to represent data in a portable, vendor-neutral, readable format and to exchange data between different systems. It's effectively turning the Internet into a middleware of Web applications in which XML is the spoken language. This article assumes that readers have a sound understanding of XML/XSL and Java Servlet concepts. I provide a small pizza order and inquiry example to demonstrate how we can use XML to develop Web applications that serve any client device or delivery channel. The code for this article can be downloaded from the XML-J Web site. It requires a basic understanding of the Servlets, XML4J and XSL code level.
XML Processing in Java
Traditional Web Application Development
The output of the Pizza inquiry can also be used to submit Pizza orders to the server. I haven't generated any HTML to submit orders; I leave it as an exercise for the reader. I assume that whenever an HTTP request is made to the AddPizzaToBasket Servlet, it contains three parameters (Pizza unique name, size and quantity). An order object is constructed against these parameters and added to the session vector that's maintained as a session variable. The request to the CheckOutServlet should have the customer name and credit card number. The customer object is constructed against these parameters and a processOrders () method is called. This method is left empty so you can do anything you want in it. The code for these servlets can be found in Listing 1. New Business Requirements from Business People Suppose you're an architect. The restaurant management talks to you about WAP technology, which would enable pizza inquiries and orders on mobile phones. They want this functionality available as early as possible in order to remain competitive. You have a problem: the WAP-enabled mobile phones can understand only WML and all your HTTP servlets are responding with HTML.
The Unstructured Approach
Another approach: the HTTP header contains information about the User Agent, which you can retrieve from the HTTP header in the servlet code. Make two separate functions: one for Web channel response generation and the other for the WAP channel response channel. Call them from the doGet () function that's based on the User-Agent value in the HTTP header (found in Listing 2).
XML-Based Structured Approach
As an architect, you'll foresee that the business people will come to you again with new requirements. Today they require a WAP-enabled application, tomorrow - B2B. Look at the unstructured solution again; it'll create problems in the B2B-based architecture extensions since the data is in the form of Java objects. These objects require RMI to travel over the wire. The other end also needs RMI infrastructure, and the solution won't work behind the firewall. The business needs a global data carrier - HTTP and language- and platform-independent data structures - such as XML. Imagine the scalability of your structured solution. Your Web server will deliver plain XML to any other B2B partner over HTTP (the Internet). This solution works for n tiers of business-logic processing in which each tier is from a different party and resides behind the firewall. XML data is independent of any client device so the delivered information can be formatted/parsed to be used in any application (HTML, WML, PDAs, ATMs, FAT/custom applications). The business-logic-generated XML data is used by all delivery channels. Only one copy of business logic is used by all types of clients. Any change in the business rules is automatically applied to all channels.
XML in Inquiry Applications
XML in Order Processing
While I was writing this article, a friend asked, "Why are you using XML to send the data to the other Web server over HTTP? Why not use the simple form field/value parameters?" I agree. This is true; a simple field/value pair can do the same task but this approach is useful for simple form data submission. What would happen if the orders have complex structures made up of multiple interrelated parameters? Where will the structure information about the data be maintained, or how will you relate one parameter to another? If you use the simple field/value parameters, the HTTP request handler code at the other partner's server should have the necessary information about the interparameter relationship. Any change in the parameters will require code changes in all the receiving Web servers. This would be a bad design from a maintenance point of view. In the case of XML the change requires only an update in the DTDs, which will be distributed to all suppliers, but the code for input validation or data extraction remains as is. Listing 4 shows the code. It's a simple process to send XML data as form data over HTTP to the partner's Web server. The response is also received as XML data. In addition, I've developed order and order acknowledgment DTDs that validate the structure of submitted or received XML data. To keep the examples simple, I've hard-coded the DTD reference paths in the XML data or document. You may want it to be separate but I'm a bit lazy! 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 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||