Java 如何将对象的属性设置为WSDL上的一个操作所需而另一个操作所不需要的属性?

Java 如何将对象的属性设置为WSDL上的一个操作所需而另一个操作所不需要的属性?,java,web-services,soap,xsd,wsdl,Java,Web Services,Soap,Xsd,Wsdl,例如,我有以下复杂类型: <!-- will be use as a request parameter --> <complextType name="enrollStudentRequest"> <sequence> <element name="student" type="Student" /> </sequence> </complexType> <!-- will be use as a

例如,我有以下复杂类型:

<!-- will be use as a request parameter -->
<complextType name="enrollStudentRequest">     
 <sequence>
  <element name="student" type="Student" />
 </sequence>
</complexType>

<!-- will be use as an operation response -->
<complextType name="retrieveStudentsResponse">
 <sequence>
  <element name="student" type="Student" minOccurs="0" maxOccurs="unbounded" />
 </sequence>
</complexType>

<!-- domain model -->
<complexType name="Student">
 <sequence name="id" type="long" />
 <sequence name="firstName" type="string" />
 <sequence name="lastName" type="string" />
</complexType>

问题:
我如何强制执行,以便在“enrollStudentRequest”上,Student.id是必需的,但在“retrieveStudentsResponse”上不是必需的?我可以在WSDL上实施这样的限制吗?

不能用当前形式的模式,不行。您要么需要重新构造WSDL/模式,要么在模式中保留它作为可选的,然后用Java执行额外的手动验证。

因此,我听到的是,我们不能单独在WSDL中进行这种限制。那么我最好用java进行验证。不,你可以用WSDL进行验证,但是你需要定义两种不同的
Student
类型,一种是可选的ID,另一种是强制的ID。但是这样它们就不再是同一种类型了,这可能很重要,也可能无关紧要。这就是我们正在尝试的,避免定义具有相同属性的多个对象。谢谢