This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
|
Make Your Legacy Apps
Work on the Internet
Scott Howlett and Jeff Dunmall |
The Internet is increasingly becoming an important path for business-to-business data services. You can use BizTalk and COM to keep your existing systems useful for longer. |
In the coming years, most companies will
integrate their Internet presence with their mission-critical line-of-business systems. Creating these applications will be the most difficult challenge Internet developers have yet to face. It means enabling interoperability between legacy systems, possibly from different companies, and doing it with the availability and scalability that Internet applications demand. By getting into the right design mindset and making the right technology choices, notably Extensible Markup Language (XML) and Microsoft® Message Queue Services (MSMQ), Internet applications can provide the return-on-investment that has been promised in the past, but rarely delivered.
First, let's explore what legacy systems are and why they're important. We'll walk you through interoperable Internet application development and the issues involved in building them. Then we'll build an Internet-based Address Change facility as a traditional Internet application that integrates with existing systems. We'll also show you how the design is extensible, enabling business-to-business communication using the BizTalk framework. Surprisingly, the framework can be written with only about 100 lines of ASP and Visual Basic® code. Microsoft will expand the technology available for integration with legacy systems when it releases the Microsoft Enterprise Interop Server, codenamed "Babylon" (see Figure 1). Babylon delivers application integration with COM Transaction Integrator (COMTI) and an MSMQ-to-MQ |
Figure 1: Microsoft Enterprise Interop Server Architecture |
Series bridge, data integration with OLE DB providers and ODBC drivers, and network/platform integration via an SNa
gateway or direct TCP/IP access. We'll only address the
challenges of getting data to the Interop server. To find out more about Microsoft's interoperability strategy, go to
http://www.microsoft.com/interoperability/.
Background
Availability, Performance, and Scalability
How to Bring Them Together
MSMQ and XML
Sample Application
Let's take a quick look at the typical Internet solution and highlight some of the pitfalls. We'll then show you a good second-generation application and its extension to a third-generation app using the approach advocated by BizTalk.org, which was announced at TechEd in May 1999.
Typical Approach
|
Figure 2: a Traditional HTML Form |
This solution does not address the availability, performance, scalability, or exception handling challenges. First, availability is not optimal because if any of the data sources are unavailable at submit time, the user will receive an error message. Furthermore, if the underlying data sources run on a mainframe (as most legacy systems do), there may also be transient problems with connectivity through the SNa gateway. And, of course, there are the usual network problems, which may be intensified if the database is located across the WAN. There is a big problem with performance: the user is waiting for all database transactions to complete. This can be disastrous, especially at busy periods (end-of-month, holidays, and so on) when legacy systems typically run at or near full capacity. Having this many database connections on a single page also presents scalability problems, especially if connections are limited (which they frequently are in legacy systems) and if there are contention issues. There may even be a show stopper if the transactions are lengthy and are locking resources. This system does not exploit existing systems, and there is no exception handling mechanism. There are also less obvious problems with this solution. What if complex business rules need to be enforced? Even worse, what if they had traditionally been enforced by a manual process? What if connectivity to the back-end database is simply not possible (existing instead in a flat file on the mainframe) or a subsystem is down for regular maintenance? What if you want to share this information with an affiliate company? This may sound like worst-case planning, but these are common concerns at large corporations.
a Better Solution
The project starts with a DTD, which defines the structure of the XML. The source code is shown in Figure 3. DTDs have their place, but they don't describe data in a way that is useful to data architects. a new standard, schemas, is emerging. Schemas use XML itself to describe the XML document structure. We chose to use XML schemas for this reason. Schemas are also a key part of the BizTalk initiative, which was started to facilitate business-to-business communications using XML. The DTD and schema serve the same goal: they allow the XML parser to validate an XML document against a reference to make sure it conforms to the published standard. An XML document that conforms to a DTD or schema is said to be valid. Schemas are currently only supported by Microsoft Internet Explorer 5.0. a sample Customer schema is shown in Figure 4. Before we get into the nitty-gritty implementation details, let's go over the entire solution first. We're taking a straightforward, six-step approach (see Figure 5):
|
Figure 7: Customer XML Document |
At this point, you've defined your XML schema, created an XML document on the client, and validated it against the schema. Now it's time to submit it to the server. To post the XML to the page, use the XMLHTTPRequest object included in the msxml.dll that ships with Internet Explorer 5.0. Using this object offers the best performance (by providing the leanest possible HTTP POST forms without compression) and the most straightforward code. The client-side source code to post the XML is shown in the SendXML method in Figure 6. Prior to Internet Explorer 5.0, the preferred method for HTTP posting would have been through the WinInet API. We've seen the code that does this, and it's not pretty. The code to receive the XML on the server is shown in Figure 8. Note the call to set the async property of the XMLDOM object to False. If you omit this line, the resolution of the schema and the eventual parsing of the document will be performed asynchronously, which is not what you want in this case. The source code that receives XML on the server is shown in the ProcessRequest method in Figure 8. The SendMessage function sends an MSMQ message to the Distributor here as well. The address change message is sent from the ASP page to the source queue shown in Figure 9. When it arrives, MSMQ notifies a Listener that calls the Distributor, a Microsoft Transaction Services (MTS) component. The Distributor pulls the message off the queue and sends the XML body to the destination queues as specified in the registry. Should something go wrong while sending the messages, the transaction rolls back, leaving the message on the source queue and nothing in the destination queues. More detailed information about sending and receiving MSMQ messages is available in Ted Pattison's article, "Using Visual Basic to Integrate MSMQ into Your Distributed Applications" (Microsoft Systems Journal, May 1999). |
Figure 9: Distributor Architecture |
To take a message off a queue in an MTS transaction, the application removing the message must be running locally on the same machine as the queue and it must be running in MTS.
The Listener
|
|
To set up notification in the Visual Basic-based listener, you'd then use the following code: |
|
Instead of using a path name here, you should use a format name to increase performance. Using a path name requires a query to the Message Queue Information Store (MQIS). That RPC call adds significant overhead to the open queue request. Using a format name, on the other hand, requires only a single RPC call to the MQIS (if it is not a direct format name). After the first call, MSMQ caches the connection information, which removes the site controller from the picture and increases performance. This will be particularly relevant in the MTS Distributor component. |
Figure 10: The Listener Application |
When an MSMQEvent_Arrived event is fired, the Visual Basic-based component calls the Distributor in MTS with the format name of the source queue. It does not pass a reference to the source queue directly; calling ReceiveCurrent on the reference would not include the source message in the transaction because the queue was not opened in the context of the transaction. If the transaction aborted, the message would neither appear in the destination queue nor remain in the source queue.
The Distributor
|
Figure 11: Registry Values |
In a more robust system, the Distributor might determine the destination based on a database lookup and the type of XML schema used in the body of the message. This more flexible architecture could be used to process other message types as well. Figure 9 gives the impression that the Distributor and destination queues are all running side-by-side on the same machine. While this is possible, it is equally likely that the Handlers would be running in separate offices, maybe even in different countries. This transparency gives your application the ability to communicate over slow links or WAN connections, knowing that your message will be processed when network conditions permit.
Benefits of this Solution
The next step would be to register another data service with the Distributor. This data service would simply post valid XMLaccording to the BizTalk customer schemato the bank, which would then process the request. In effect, the bank would not be able to tell if the XML request came directly from a customer or via his insurance company. Version 3 of MSMQ is slated to support native HTTP message delivery that extends the guaranteed delivery concept across the Internet (version 2 is scheduled for release as part of Windows 2000). Figure 14 extends the conceptual diagram of the system, making this a business-to-business solution. As you can see, extending a second-generation application to include business-to-business operations is quite naturalespecially if the BizTalk framework is used to standardize on the use of a single XML schema.
Conclusion
|
http://msdn.microsoft.com/xml/articles/hess061499.asp and http://msdn.microsoft.com/xml/default.asp |
From the September 1999 issue of Microsoft Internet Developer.
|