Interoperable Types for XML Serialization
When you use XML Serialization, you must use interoperable, or interop, parameters and return types, as follows:
|
Type |
Description |
|
Primitives |
|
|
|
Interoperability between Calendar and DateTime in a mixed Java/.NET setup does not support time zones. .NET's DateTime structure does not support the concept of timezone so that information is not maintained. You must send that information separately. The timezone itself is not preserved across serialization so all Calendar objects are created with local timezones. .NET has an additional limitation in that it assumes that all date time data is in its local timezone. Therefore, serialization of XML not in that local timezone produces an incorrect time. If you cannot determine the .NET deserializer's local timezone from Java to set in the Calendar, pass the Calendar data as a String instead. |
|
Arrays |
The type can be an array of any interop type. |
|
User-Defined Types |
User-defined types can be used, as long as they follow the standard “bean” pattern. For both languages, use interoperable types (including other user-defined types) for all data. For Java, all data must be Java Bean properties; that is, each must have public get/set methods. For .NET, all data must be public fields. When generating a proxy for this Service type, user-defined types result in generated classes. You can have other data and methods in the type, such as private non-interop fields, but they are ignored and not reflected in the generated class. Also, user-defined types must be concrete; abstract classes and interfaces are not allowed. |
|
Data References (Java and .NET) |
This type can be used as an argument, return type, or GridCache object, and is interoperable whether XML Serialization is on or off. When generating a proxy for a Service type using Data References, it does not include all methods of the Data References. Normally, the data in a Data Reference is stored and served in the file server on the GridServer component that created it. C++ Data References are not interoperable with Java or .NET. For more information, see Data References. |
The following is an example of a Java Interop type:
public class Valuation {
private java.util.Calendar valuationDate;
private double value;
private MarketData data;
private String[] names;
public Valuation() {}
public java.util.Calendar getValuationDate() {
return valuationDate;
}
public void setValuationDate(java.util.Calendar
valuationDate) {
this.valuationDate = valuationDate;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
public String[] getNames() {
return names;
}
public String getNames(int index) {
return names[index];
}
public void setNames(String[] names) {
this.names = names;
}
public void setNames(int index, String name ) {
this.names[index] = name;
}
}
public void setValuationDate(java.util.Calendar valuationDate) {
this.valuationDate = valuationDate;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
}
The following is an example of a .NET Interop type:
[Serializable]
public class Valuation {
public DateTime valuationDate;
public double value;
}