Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to define nested structures inline
xomega
#1 Posted : Tuesday, August 14, 2012 6:27:45 PM(UTC)
xomega



Any time that you need to define a structure either for the input/output of your service operation or as part of another structure, you have one of the two options: define the structure inline as an integral part of the same input, output or standalone structure; or define the structure as a standalone reusable named structure outside the context of the current structure and then just reference it by name in the current structure.

The following tutorial shows you the steps for the first option, which provides the simplicity of defining the whole structure in-place, but has a limitation of not being able to reuse the same structure in other structures or operations.
  1. Add nested elements inside the output, input or struct element that defines your current structure as follows.
  2. To describe a single parameter add a param element. Give it a unique name within the structure by setting the name attribute.
  3. To specify the parameter type set the type attribute to the name of a logical type defined in the model. Note, that if the parameter name matches a field name in the current object (or in the object specified by the object attribute on the standalone structure), then you don't have to specify the parameter type. In this case the type of that field will be used, which reduces the maintenance in case if you need to change the field type.
  4. To specify whether or not the parameter is required set the required attribute to true or false accordingly. If not set explicitly, the required attribute will be inherited from the field with the matching name in the current object or the object specified by the object attribute for a standalone structure.
  5. To specify that the parameter is a collection of values rather than a single value, set the list attribute to true.
  6. In order to add a nested structure as opposed to a single parameter, add a struct element inside the element for your current structure. Give it a unique name within the structure by setting the name attribute.
  7. To specify a collection of structures rather than a single nested structure, set the list attribute to true.
  8. If you want to define the nested structure inline, then repeat these steps for that structure.
  9. You can also define the nested structure separately in the model and/or reference an existing standalone structure by setting the ref attribute to the name of that structure.

Here's an example of an operation output structure defined inline.
Code:
<operation name="search flights">
  <output list="true">
    <param name="flight" type="flight number" required="true"/>
    <param name="origin" type="airport code"/>
    <param name="destination" type="airport code"/>
    <param name="departure" type="time"/>
    <param name="schedule" type="day of week" list="true"/>
  </output>
</operation>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright © 2009-2022 Xomega.Net. All rights reserved.