Dimuthuc’s Weblog

Just using what others shared..

Last JIRA for the Year 2007

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 | , , , , , | No Comments Yet

adb with base64Binary and xmime.xsd – little howto (Sending binary with Axis2/WSDL2C)

This is to put a pointer to a mail in axis2/c user list appeared few months ago, It is a little how to on using Axis2 WSDL2C to generate code to send binaries. Please check the following link to find the howto. http://markmail.org/message/sdkccr3ixve3psyv (It will be on a zip file)

There Mark Nüßler is sharing his experience of sending binaries with Axis2/C specially from WSDL2C generated code.

Hope he will excuse me for mentioning it here.:)

December 6, 2007 Posted by dimuthuc | WSDL2C/ Codegen, Web services, axis2/c | , , , , , , | 1 Comment

Axis2/C codegen helper tools

In a case somebody feel not well to work with the WSDL2C tool, I have written some scripts to help generating demos, writing tests and building code. From that I think the demo generation script should be really useful. It s a ruby script and you can download it from here. (http://people.apache.org/~dimuthu/leisure_time.html, check the script under 23th October 2007)

What you should do is generate the code using WSDL2C tool (It can be either stub or skel), and run the script within the generated files. If it is stub, then there will be a demo.c file, which is a complete demonstration of writing all the operation using ADB objects. And if it the skel, then the demo filename will be axis2_skel_myservice2.c (axis2_skel_myservice.c is the original generated file). That has implemented some fake logic to show how each operation can be built using ADB.

I hope this will be useful to people who are searching for WSDL2C tags.:)

December 1, 2007 Posted by dimuthuc | WSDL2C/ Codegen, Web services, axis2/c | , , | 6 Comments

Axis2/C Codegen new features

Well, I m right now looking in to fixing a very basic bug in the axis2/c codegen templates. I m wonder how it ran so much time without fixing this, Anyway thanks for the questions in the mailing list, I thought I should spend sometime on this in this weekend!!! Yea I remember I should prepare to do a RC on wsf/ruby next moday:).

The bug is, the tool is never handling nillable elements and optional attributes. And even worse! in serializing you can never generate a nil element, the code will set some default value at wherever you didn’t specify a value.

The fix is very simple, At deserializing, we can always check whether the element is nillable from the schema, if so at runtime, we check whether the wanted element is having the attribute xsi:type=’nil’. or simply just first child is NULL.

At serializing, we may keep another variable to track each inner element is valid or not. If a non-nillable element is not valid we can complain.

Next thing what are the functions we should provide to deal with nil things. For an example if we take the following schema component,

<xs:element name=”Book”>
<xs:complexType>
<xs:sequence>
<xs:element name=”Title” type=”xs:string”/>
<xs:element maxOccurs=”unbounded” name=”Authors” type=”xs:string”/>
<xs:element name=”Publisher” nillable=”true” type=”xs:string”/>
<xs:element name=”Price” nillable=”true” type=”xs:int”/>
</xs:sequence>
</xs:complexType>
</xs:element>

Here the function available to set/get publisher would be,

adb_Book_set_Publisher(.., axis2_char_t *publisher)

axis2_char_t* adb_Book_get_Publisher(..)

So whenever publisher need to be kept nil, you can pass NULL to the set_publisher function.

But this won’t work when it come to an int. So there will be additional two functions to set and get the nil value associated with the price.

adb_Book_set_Price(.., int price)

int adb_Book_get_Price(..)

adb_Book_set_Price_nil()

axis2_bool_t adb_Book_is_Price_nil(..)

I think for consistancy we should have set_nil and is nil for all the nillable properties (I m not sure should we need to have this for even non-nillables)

And how if the Publisher inner element is changed to something like this,

<xs:element maxOccurs=”unbounded” name=”Publishers” nillable=”true” type=”xs:string”/>

Then the the functions to be added will be,

adb_Book_add_Publishers_nil()

axis2_bool_t adb_Book_is_Publishers_nil_at(..)

Whenever adb_Book_set_Publishers_at is available, adb_Book_is_Publishers_nil_at will also be available hopefully.

Is this looks like a mess?, but unfortunately it is how this should be changed.

November 16, 2007 Posted by dimuthuc | WSDL2C/ Codegen, Web services, axis2/c | , , , , | No Comments Yet