WSClient++ generates empty class for element of default type

53 Views Asked by At

In my XSD I have something like this

<xs:element name="type">
    <xs:complexType>
        <xs:choice>
            <xs:element name="type1"/>  <---CHECK THIS
            <xs:element name="type2">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="type21" type="xs:int">
                            <xs:annotation>
                                <xs:documentation>in seconds</xs:documentation>
                            </xs:annotation>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="type3">
             .....Further XML....

For type1 type element, nothing is specified. And I used WSClient++ to generate my stub. WSClient++ generated just an empty class. What exactly I need to infer from this. And how do I handle this.

Class generated by WSClient++

package com.xyz.abc.conf

public class Type1
{

}

and this is what is returned by server

<type><type1/></type>

when I try to de-serialize this, it gives me null pointer exception. how do I handle this.?

1

There are 1 best solutions below

2
On

If you don't specify a type for an element, the default type is xs:anyType which allows any XML content whatsoever. It's a little bit difficult to map that to a Java class.