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

Notification

Icon
Error

How to specify a collection for operation parameters
xomega
#1 Posted : Wednesday, August 8, 2012 6:31:46 PM(UTC)
xomega



When defining parameters for service model operations or standalone reusable structures there are multiple ways of how to specify a collection as opposed to a scalar parameter or a structure. In general it all boils down to setting the list attribute to true on the corresponding element in the structure as follows.

  • If you want to specify an array of values as opposed to a single value then you can set the list attribute to true on the corresponding param element.
  • If you want to specify a list of structures (i.e. a table) then you can set the list attribute to true on the corresponding struct named element. You have an option to either reference an existing structure by setting the ref attribute to that structure's name or you can define the structure inline by adding nested param or struct elements inside that struct element.
  • Similarly, if you want the input or output of your operation to accept or return a list of structures respectively, then you need to set the list attribute to true on the corresponding input or output element. As described above, you can make the input or output structure reference an existing structure or define the structure inline.

The following snippet demonstrates these various scenarios for specifying a collection.
Code:
<operation name="search flights">
  <input>
    <param name="airlines" type="customer" list="true"/>
    <struct name="origins" ref="location struct" list="true"/>
    <struct name="destinations" list="true">
      <param name="city" type="city name"/>
      <param name="state" type="state"/>
    </struct>
  </input>
  <output list="true">
    <param name="flight" type="flight number"/>
    <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.