如果我想在XSD中获得List<UserModel>
响应,我不确定我是否正确这样做。
假设我有一个这样的用户类:
public class UserModel {
private String eMail;
private String name;
private String type;
private List<String> groups;
private String lastUpdated;
private String updatedBy;
(assumed the getters and setters are already here...)
}
如果我想为SOAP构建XML模式(XSD),我是否正确地执行此操作?
<xs:simpleType name="stringList">
<xs:list itemType="xs:string"/>
</xs:simpleType>
<xs:element name="userListEntity">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="userEntity"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="userEntity">
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="type" type="xs:string" />
<xs:element name="groups" type="tns:stringList" />
<xs:element ref="lastUpdated" />
<xs:element ref="updatedBy" />
</xs:sequence>
<xs:attribute name="eMail" type="xs:string" use="required" />
</xs:complexType>
<xs:element name="lastUpdated" type="xs:string" />
<xs:element name="updatedBy" type="xs:string" />
答案 0 :(得分:0)
<xs:element name="groups" type="xs:string" maxOccurs="unbounded" minOccurs="0" nillable="true"/>
应该解决你的目的
答案 1 :(得分:0)
<xs:simpleType name="stringList">
<xs:list itemType="xs:string"/>
</xs:simpleType>
<xs:complexType name="userListEntity">
<xs:sequence>
<xs:element name="userEntity" maxOccurs="unbounded" type="tns:userEntity"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="userEntity">
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="type" type="xs:string" />
<xs:element name="groups" type="tns:stringList" />
<xs:element name="lastUpdated" type="xs:string" />
<xs:element name="updatedBy" type="xs:string" />
</xs:sequence>
<xs:attribute name="eMail" type="xs:string" use="required" />
</xs:complexType>
我猜我自己解决了这个问题。我去http://www.utilities-online.info/xsdvalidation/#.UygxIvmSwUs检查并验证成功。我不确定为什么在复杂类型时不能使用引用。它告诉我&#39; ref&#39;找不到命名空间。