Today I managed to commit the code for support simple type lists for WSDL2C tool. The user interface for handling list is exactly the same as arrays. So the generated code provides set_at, get_at, add, sizeof and remove operations for the list properties.
(1)
<xs:element name=”ElementArray”>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs=”unbounded” name=”Element” type=”xs:string”/>
</xs:sequence>
</xs:complexType>
</xs:element>
(2)
<xs:element name=”SimpleList”>
<xs:simpleType>
<xs:list itemType=”xs:string”/>
</xs:simpleType>
</xs:element>
The above two schema representation would be serialized as in the following xml.
(1)
<ElementArray>
<Element>String1</Element>
<Element>String2</Element>
</ElementArray>
(2)
<SimpleList>String1 String2</SimpleList>
But when you look at the WSDL2C generated API, you will see the same set of functions are there to access and modify these values .
That is,
adb_ElementArray_add_Element() <—> adb_SimpleList_add_SimpleList()
adb_ElementArray_set_Element_at() <—> adb_SimpleList_set_SimpleList_at()
adb_ElementArray_get_Element_at() <—> adb_SimpleList_get_SimpleList_at()
adb_ElementArray_sizeof_Element() <—> adb_SimpleList_sizeof_SimpleList()
adb_ElementArray_remove_Element() <—> adb_SimpleList_remove_SimpleList()
Similarly we can provide the same API to complex type choice and simple type union, although they are also serialized completely differently.
(1)
<xs:element name=”ElementChoice”>
<xs:complexType>
<xs:choice>
<xs:element name=”StringElement” type=”xs:string”/>
<xs:element name=”IntElement” type=”xs:int”/>
</xs:choice>
</xs:complexType>
</xs:element>
(2)
<xs:element name=”SimpleUnion”>
<xs:simpleType>
<xs:list memberTypes=”xs:string xs:int”/>
</xs:simpleType>
</xs:element>
And these will be serialized in to the following kind of xmls,
(1)
<ElementChoice>
<StringElement>String1</StringElement>
</ElementChoice>
Or
<ElementChoice>
<IntElement>5</IntElement>
</ElementChoice>
(2)
<SimpleUnion>String1</SimpleUnion>
Or
<SimpleUnion>5</SimpleUnion>
Which one to be serialized is decided on the basis which was the last to set. So the user can freely set the desired value at anytime, without worrying about freeing or resetting earlier values.
The code for handling ‘xs:choice’ is already there ( just from yesterday), And the union support will also be implemented very soon.(What I should do is just edit some xsl files, the engine is already there with WSDL2Java tool). Then WSDL2C will be able to serve for most of the ‘WSDL’s without many problems.
December 31, 2007 -
Posted by
dimuthuc |
WSDL2C/ Codegen, Web services |
choice, list, maxOccurs, union, WSDL2C, XML Schema |
No Comments Yet
No comments yet.