我有这样的xsd-
<xs:complexType name="ChoiceListItem">
<xs:sequence>
<xs:element name="childChoices" maxOccurs="unbounded" minOccurs="0" nillable="true" type="tns:ChoiceListItem"/>
<xs:element name="name" nillable="true" type="xsd:string"/>
<xs:element name="stringValue" nillable="true" type="xsd:string"/>
<xs:element name="integerValue" nillable="true" type="xsd:int"/>
</xs:sequence>
</xs:complexType>
在这里您可以看到我的 childChoices类型是在其下定义的ChoiceListItem 。这是我的Java类-
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ChoiceListItem", propOrder = {
"childChoices",
"name",
"stringValue",
"integerValue"
})
public class ChoiceListItem {
@XmlElement(nillable = true)
protected List<ChoiceListItem> childChoices;
@XmlElement(required = true, nillable = true)
protected String name;
@XmlElement(required = true, nillable = true)
protected String stringValue;
@XmlElement(required = true, type = Integer.class, nillable = true)
protected Integer integerValue;
当我在SOAPUI中运行它时,它没有显示childChoices值,但显示了其他三个项目。这是我的输出响应-
<ns3:getChoiceListItemsResponse xmlns:ns3="http://getservice.service">
<getChoiceListItemsReturn>
<items>
<ChoiceListItem>
<name>AD SERVICE</name>
<stringValue>AD SERVICE</stringValue>
<integerValue xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</ChoiceListItem>
我猜xsd定义不正确。有人可以帮助我定义正确的xsd,其中序列元素类型引用相同的Complex类型吗?
答案 0 :(得分:0)
我已通过对xsd进行更改来解决了该问题
<xs:complexType name="ChoiceListItem">
<xs:sequence>
<xs:element name="childChoices" nillable="true" type="tns:ChoiceListItemArray"/>
<xs:element name="name" nillable="true" type="xsd:string"/>
<xs:element name="stringValue" nillable="true" type="xsd:string"/>
<xs:element name="integerValue" nillable="true" type="xsd:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ChoiceListItemArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="ChoiceListItem" nillable="true" type="tns:ChoiceListItem"/>
</xs:sequence>
</xs:complexType>