The start of this chapter outlined three challenges to cross-platform data exchange: primitive data type mappings, nonexistent data types, and complex data types. Primitive data type mappings present the challenge of mapping types from one platform to equal types on the other. If the data type doesn't exist on one platform, there is a second challengethat is, to convert it to a type that does exist on the other platform. Finally, when we deal with complex data types, we must ensure that they are sent using a structure and format that can be understood by both platforms.
To wrap up this chapter, here are three recommendations for meeting these challenges and successfully exchanging data between .NET and Java:
Use XSD to define common types. As the second half of the chapter illustrated , XSD can be used to define shared types, which with the right toolscan be used to generate platform-specific code. Some organizations set up an "XSD repository" for their development teams . This is a great idea and gives developers a central resource for examining and maintaining data types that are common throughout the business.
Avoid exposing elements that are not contained in XSD. As the start of the chapter implied , some data types exist on one platform but don't exist on the other. When defining types that will be exchanged between .NET and Java, stick to the types that are published in XSD.
Use test harnesses to verify data types before writing your application. When it comes to creating solutions that need to interoperate between .NET and J2EE, start with the data types: determine which types need to be sent and the format for doing so. Once the data types have been defined, it's always useful to create a test harness . A test harness is a simple program that demonstrates the exchange of the datasimilar to the samples presented in this chapter. You can use this test harness to prove that the data exchange will succeed, before you make any investment in creating the user interface or other elements of the application.