At the most basic level, implementing interoperability between application platforms involves the exchange of data. When implementing a .NET and J2EE interoperability project, you confront three main data exchange challenges. The three challenges are:
Primitive data type mappings
Non-existent data types
Complex data types
Primitive data types are components based on the underlying type system for .NET or Java, for example, Integer, Strings, Doubles, and so on.
All challenges involve type compatibility and have the potential to hinder or prevent data transfer.
These three challenges break down as follows:
Primitive data type mappings — You may know that the type “String” exists in both the CLR and in Java. However, this does not mean that java.lang.String in Java maps exactly to System.String in .NET. If your sample exposes java.lang.String, how do you go about mapping this to its equivalent in the CLR?
Non-existent data types — How do you map data types on one platform that don’t exist in the other? For example, System.Collections.Specialized.HybridDictionary is a documented data type in the CLR, but nothing in Java resembles it in the slightest. Java contains similar examples that are not in .NET, such as Java.util.Vector.
Complex data types — Your application may expose complex data types, made up of numerous or even nested primitive data types. Here you need to expose the complex data type so that the other platform can use it.
Consider the example of integrating an ASP.NET Presentation tier with a J2EE Business tier as Figure 3.1 shows. In this example, an EJB in the J2EE Business tier exposes a method that the ASP.NET Presentation tier then calls. In a production application, this returned data is unlikely to be a simple “Hello World” string, and would probably contain complex elements.
Figure 3.1: ASP.NET Presentation tier linked to J2EE Business tier
Luckily, a number of possibilities exist that allow applications to exchange data types from one platform to the other, and Chapters 4 and 5 cover these options in detail. However, before you can make the connection between the two platforms, you have to ensure that both sides understand a particular data type before they attempt to exchange it, and also that you have a means of making the transfer that both sides can use. This next section looks at how you can use serialization to make the transfer.