Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
 I'm developing a java web service which should be consumed by .NET client. Generally, it shouldn't be any problem, this technology is quite mature this days.
 However, there is problem with some particular data type. On the object level, I have a cycling graph reference. Obviously this can't be serializaed as a plain XML document. The most straightforwad approach is;
xsd:ID/xsd:IDREF usage, which handles such case, for example:
XML
<xs:complexType name="a">
  <xs:sequence>
    <xs:element name="id" type="xs:ID" minOccurs="0"/>
    <xs:element name="myB" type="xs:IDREF" minOccurs="0"/>
    <xs:element name="someAfield" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="b">
  <xs:sequence>
    <xs:element name="id" type="xs:ID" minOccurs="0"/>
    <xs:element name="myA" type="xs:IDREF" minOccurs="0"/>
    <xs:element name="someBfield" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

The problem with IDREF is that on the design time the reference is not strictly typed. I.e., if such schema is imported to .NET, the type of field, specified by IDREF, will be an object, i.e. completely opaque. Of course, it looks not good.
In java (jaxb) there is a way to hint the type referenced by IDREF, using jaxb:property, for example:
XML
<xs:complexType name="b">
  <xs:sequence>
    <xs:element name="id" type="xs:ID" minOccurs="0"/>
    <xs:element name="myA" type="xs:IDREF" minOccurs="0"/>
      <xs:annotation>
        <xs:appinfo>
          <jaxb:property>
            <jaxb:baseType name="a"/>
          </jaxb:property>
        </xs:appinfo>
      </xs:annotation>
      </xs:element>
    <xs:element name="someBfield" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

Thus, the generated code will be strongly typed: the field "myA" will have a type "a".
Is there such thing in a .NET?

Greatly appreciating any inputs,
Sincerely,
A.
Posted
Updated 22-Jan-11 1:09am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900