0

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.?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Android
  • 3,828
  • 9
  • 46
  • 79
  • Did you use your WSDL to generate the stubs in WSClient++? If so, can you post a portion (or all) of the WSDL file for this SOAP service? – Tim Biegeleisen Jun 17 '15 at 05:56

1 Answers1

2

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Unfortunately I am working on Java only. Any suggestion? What exactly should be done? – Android Jun 17 '15 at 09:16
  • 1
    No idea, sorry. XSD is good at handling stuff with semi-structured content, Java isn't. Personally, I wouldn't use Java: you always hit this kind of "impedence mismatch". Use languages that understand the XML data model, like XSLT and XQuery. – Michael Kay Jun 17 '15 at 16:45