My blog has moved and can now be found at http://blog.aniljohn.com

No action is needed on your part if you are already subscribed to this blog via e-mail or its syndication feed.

Sunday, December 11, 2005
« Interoperability (J2EE and .NET) Article... | Main | Guest lecture on SOA, Web Services and I... »

I've written previously about the mismatch that sometimes happens when trying to map XML to a language implementation class.  Some of the issues that I've run into are probably worth documenting.

  • In consistent support for the <choice> content group in JAX-RPC
           
    When you are defining content groups in a schema, you can use Sequence, Choice or All. We had a case where the most appropriate one to use would have been the <Choice> content group. Unfortunately JAX-RPC implementations do not support this XSD construct consistently. [Note to self: Need to find out if the latest release of Apache Axis (1.3.x) has improved support for this]
    UPDATE (12/16/05): Was informed today that the JAX-RPC implementation of Apache Axis 1.2.1 supports <choice>.

    The work around for this was to use a <Sequence> content group but mark the elements as optional i.e. use minOccurs=0.
  • Lack of support for an empty instance of the anyURI data type in .NET
           
    In .NET v1.1, there is a problem with schema validation of xs:anyURI data type in the .NET System.Xml.XmlValidatingReader. In reading an explanation of this from Dare Obasanjo [MSFT] some time ago, it would appear that he schema validation engine in the .NET Framework uses the System.Uri class for parsing URIs. This class doesn't consider an empty string to be a valid URI which is why the .NET schema validation considers the empty instance of anyURI to be invalid according to its schema.

    The long and the short is that this is supposed to be fixed in the .NET 2.0 [Note to self: Verify!]. The work around for this is to change the data type from xs:anyURI to xs:string. 
  • Lack of support for XSD Schema Substitution Groups in the .NET XML Serializer. 
            
    In some of the schemas that I work with, Substitution groups are used extensively. I would think that one of the work arounds for this is to use the <choice> content group. The issue of course is that we cannot because of the first issue; JAX-RPC support! So we are in effect caught between a rock and a hard place.

    The work around for this was to go through each of the elements that use a substitution group and make an explicit choice on which one we will use/support and modify the schema to reflect that. [Note to Self: Bug Microsoft to support this construct :-)]
  • Lack of support in Java for default values and optional attributes.

    The optional and default attributes in a schema are simply ignored when you generate the server-side bindings. On the other hand, I really am not a fan of validation adding items that will be passed on the wire without my explicit say-so, hmm..
  • In the Java type model, all object references can be null but in .NET 1.1 value types always have a value and as such cannot be set to null. Only reference types can be null. Nullable types in .NET 2.0 address this issue.

    Be aware of and avoid the usage of nillable=”true” for value types! Another recommendation that I’ve seen is to define a complex type to wrap a value type.

Just to close out, here is a listing of Cross-Platform Safe Types:

XML Schema .NET - CLR Java
xs:string String String
xs:int* int int
xs:dateTime* DateTime Calendar
xs:float* float float
xs:double* double double
xs:boolean* bool boolean
xs:enumeration** Enum Enum

* avoid nillable=”true”
** avoid QName values (colons in data)

From those who have experienced the pain of working through Interop, I would appreciate any corrections, additions and work-arounds to the listing.

Comments are closed.