[Download] | [Documentation Home] | [Release Note]

Array Data Support

Introduction

Array data type support bringg data services the ability to dynamically provide a set of values without knowing the size of the data set beforehand. This is handled in WSO2 Data Services Server using the array parameter type. Usually used single parameter types being scalar parameter types, arrays bring the option of building more complex queries depending on the input.

Adding Array Data Types to Data Services

Input Mappings

In the input mappings section, when adding a new entry, the "Parameter Type" should be selected as "Array". This step is showed in Figure 1.


Figure 1: Adding array parameter types to input mappings.

Array Representation in the Message

Internally, how the array types are handled in the message level is as follows. In the SOAP envelopes body, when the parameters are serialised, in scalar types, there will be only one element per parameter. In the situation of an array type, simply the element representing the parameter will be repeated. The following section shows a sample SOAP message which contains the array type "employeeNumbers".

 

...
<s:Body>  
   <p:setSalaryForEmployees xmlns:p="http://ws.wso2.org/dataservice/samples/rdbms_sample">  
      <salary xmlns="http://ws.wso2.org/dataservice/samples/rdbms_sample">15000</salary>  
      <employeeNumbers xmlns="http://ws.wso2.org/dataservice/samples/rdbms_sample">1002</employeeNumbers>  
      <employeeNumbers xmlns="http://ws.wso2.org/dataservice/samples/rdbms_sample">2014</employeeNumbers>  
      <employeeNumbers xmlns="http://ws.wso2.org/dataservice/samples/rdbms_sample">4411</employeeNumbers>  
   </p:setSalaryForEmployees>  
</s:Body>  
 </s:Envelope>  

          

The array types are properly mentioned in the WSDL generation, so when using a service which was code-generated from the WSDL, the array type will be suitably represented.

Demo

For a demonstration of the usage of arrays, refer to the RDBMS Sample.