WSDL is as follows:
<xsd:element name="Parent"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" ref="tns:Child"/> </xsd:sequence> </xsd:complexType> </xsd:element>
Expected Behavior
If I pass Axis 1.4 WSDL-based Java code, I expect the following field in my object:
public class MyComplexObject { private Parent parent; }
The Parent class will consist of an array of Child objects.
public class Parent { private Child[] child; }
Actual behavior
The actual behavior is that the list of Child objects is defined directly at the parent object level:
public class MyComplexObject { private Child[] parent; }
When we call webservice, filling the array, it will result in the following XML:
<Parent> ... </Parent> <Parent> ... </Parent>
causes server-side failures. Axis seems to be having difficulty with nested arrays of complex types. Anyone who encounters the same problem and knows any workarounds / fixes?
conclusions
After some research, I was able to produce the expected behavior by adding a dummy field to the XSD definition:
<xsd:element name="Parent"> <xsd:complexType> <xsd:sequence> <xsd:element name="Dummy" type="xsd:string"/> <xsd:element maxOccurs="unbounded" ref="tns:Child"/> </xsd:sequence> </xsd:complexType> </xsd:element>
It seems that in this case, Axis creates the Parent wrapper object correctly:
public class Parent { private String dummy; private Child[] child; }
And my XML output is correct:
<Parent> <Dummy>...</Dummy> <Child>...</Child> <Child>...</Child> </Parent>
So it seems that this is really a bug in Axis 1.4 ...