|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TODAY'S TOP SOA & WEBSERVICES LINKS Building Distributed Applications with Corba and XML
By: Dermot Russell; Nick Simha
Digg This!
XML and CORBA are key technologies for building distributed systems, but both have evolved separately by addressing different needs of content management and distributed applications. This article illustrates how these technologies can benefit from each other.
XML
CORBA A distributed application consists of three logical components - data, logic and transport. CORBA ties these three components together in the form of distributed objects in which the logic is implemented using some OO language. The data is tied to the transport and transferred in binary form between the client and the server. The familiar function call paradigm is used to invoke methods on remote objects transparently. In contrast, XML is only about data, which is represented as text and not inherently tied to any transport protocol. It can be carried over any transport protocol that's capable of transporting textual data. The XML programming model consists of walking a parsed XML document and taking action based on the elements encountered. Using XML for data gives us the ability to describe arbitrarily complex data types, build loosely coupled systems, easily transform data from one form to the other and easily display data in browsers. XML parsers are available for most languages and operating systems; thus it's easy to embed a parser with an application. XML support is also present in the popular browsers, giving developers the ability to display XML data. CORBA has been used successfully to interface with legacy and ERP systems. Using XML instead of IDL types may, in certain cases, make this integration even easier. Many ERP vendors have pledged XML support in their products, which would make the use of XML even more attractive. A distributed system that uses CORBA for distribution and XML for data gives us the best of both worlds, and at the same time builds on two open industry standards. The following section looks at the specifics of how this integration can be achieved.
Integrating XML and CORBA XML documents, which are textual in nature, define two popular programming APIs:
The interfaces of CORBA objects and the types of data they can manipulate are defined using IDL. Thus the integration of XML with CORBA must be expressed using IDL types. However, it's possible to perform this transformation dynamically when IIOP-compatible structures can be created directly from XML documents. IDL provides standard primitive data types along with structured and aggregate data types and variable types in the form of the CORBA Any (and DynAny). IDL distinguishes between object types and value types as noted in the sidebar below. It's not desirable to produce an XML IDL API using CORBA object types. This would imply that the XML document is encapsulated within a CORBA interface, which would be inefficient since the document is accessed in a remote fashion. It's more desirable to use either value types or existing IDL data types as a means of passing documents by value, since this would allow efficient operations on the XML document. However, the value-types specification has only recently been ratified by the OMG, and few implementations of the specification are available. Thus the choice remains about whether the integration of XML and CORBA should use value types or map directly to existing CORBA data types.
Approach 1: Simple Approach
struct XMLDocument
typedef sequence<XMLDocument> XMLDocuments;
interface MyObject
Approach 2: Mapping XML to IDL Using Value Types Listing 1, taken from OMG Document 99-12-05, demonstrates the value-type definition for a DOM Node. The Node type is central to the DOM API, since the document, element and text sections of an XML document implement the Node interface. As you can see, this API uses a standard naming convention for accessing all parts of an XML document. Other Key DOM types are DOMString, NodeList, Document, Element, Attr and Text. This approach is consistent with the standard DOM API; however, the semantics of the XML document aren't clear when using a standard API. It's also likely to be some time before such an approach is practical, as the CORBA implementation of the value-type specification hasn't become common yet.
Approach 3: Mapping XML to CORBA IDL The examples that follow demonstrate the mapping between an XML document and its associated CORBA IDL definition. This mapping could be performed automatically given a DTD (or XML schema) for the XML document in question. XML documents are implemented as a hierarchical CORBA type using a two-way mapping between XML and IDL and the CORBA Any. In this case, the CORBA Any will always hold a CORBA structure, and the contents of this structure depend on the XML document. The mapping is detailed as follows:
Mapping XML ---> IDL
<element>
struct element
<element color=green' font=fixed'/>
string color,
<element color=green'>
<element>
struct element
<elements>
struct elements
<elements>
interface MyObject
Mapping IDL ---> XML
This type-safe and efficient approach takes advantage of the available CORBA implementations. An example of mapping XML to CORBA taken from the finance domain demonstrates the mapping of a stock portfolio XML document to a CORBA IDL (see Listing 2).
Summary The second approach, which attempts to leverage from the standard DOM API to XML, presents a solution using the newly defined CORBA value-type specification. While this solution is efficient and type-safe, it doesn't attempt to map the semantics of the document into the CORBA value type. The final approach achieves efficiency and type safety, and succeeds in preserving the semantics of the XML document in the CORBA structure. It's also possible to implement this approach with the currently available CORBA implementations.
References 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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||