【发布时间】:2019-07-22 21:04:03
【问题描述】:
我有这样的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,其中序列元素类型引用相同的复杂类型吗?
【问题讨论】:
标签: soap xsd schema xsd-validation complextype