views:

19

answers:

1

For example I have these complexTypes:

<!-- 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>

The question: How can I enforce so that on "enrollStudentRequest", Student.id is required BUT not required on "retrieveStudentsResponse"? Can I enforce such a restriction on the WSDL?

A: 

Not with the schema in its current form, no. You either need to restructure the WSDL/schema, or keep it as optional in the schema, and then perform additional manual validation in Java.

skaffman
so, what i'm hearing is that we cannot do this kind of restriction in wsdl alone. i'd better do the validation in java then.
No, you *can* do it in WSDL, but you'll need to define two different `Student` types, one with an optional ID, and one with a mandatory ID. But then they wouldn't be the same type any more, which may or may not matter to do.
skaffman
that's what we are trying to do, avoiding to define many objects with the same properties. thanks!