This documentation is for WSO2 Application Server 5.2.0. View documentation for the latest release.
Data Types - Application Server 5.2.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata

Array parameter type enables data services to dynamically provide a set of values without knowing the size of the data set beforehand. Generally, more than single data types, arrays enable building queries for more complex inputs. Array data type is available as a parameter type when creating Input mappings for your queries, which are defined while creating data services. For example,

For more information on creating data services, refer to the relevant Data Source under section "Create a Data Service Using Various Data Sources."

Array Representation in SOAP Messages

This is how array types are handled internally in the message-level. When the parameters are serialized (in scalar types) there is only one element per parameter in the SOAP message. In arrays, the element representing the parameter is repeated. For example, refer to the sample SOAP message below, which contains the array type "employeeNumbers".

   <p:setSalaryForEmployees xmlns:p="">
      <salary xmlns="">15000</salary>
      <employeeNumbers xmlns="">1002</employeeNumbers>
      <employeeNumbers xmlns="">2014</employeeNumbers>
      <employeeNumbers xmlns="">4411</employeeNumbers>

Array types are properly mentioned in the WSDL generation. As a result, the array type is suitably presented in a service which is code-generated.

Binary Data 

When using data services, users come across the need to transfer binary data from/to the server. This is handled using Base64 encoding. When sending, binary data should be encoded in Base64 format. Similarly, when receiving, the receiving character data must be Base64-decoded in order to retrieve the original binary data back.

Binary data type is available as an "SQL Type" when creating Input Mappings for your queries, which are defined while creating data services. For example,

When defining the result of a data service, in order to declare that a binary value is expected, you have to add a suitable entry in Output Mappings. The "Schema Type" of the Output Mapping should be selected as "xs:base64Binary." For example,

When using code-generated clients, the encoding/decoding of Base64 data need not be explicitly done by the user since the existence of binary data is mentioned in the WSDL. For example, in Axis2 code-generated stubs, the binary types are handled using the "DataHandler" class.

User-Defined Types

Apart from the standard data types (such as Varchar, Integer etc.) the 'Data Service Hosting' feature also supports querying of custom objects, which are usually called User Defined Types (UDT). Users can query UDTs with ordinary SQL queries as well as OUT parameters of stored procedures.

Query UDTs with Ordinary SQL Queries

In this option, you are only required to define an output mapping corresponding to the UDT to be queried. An important point is that the attributes of a UDT is queried depending on the order they are specified in the UDT. For example, if the UDT carries the structure below, the attribute index "0" maps to the attribute "Id".

"SampleUDT{Id Integer, Name Varchar(100)}"

Similarly, attribute "Name" can be retrieved via the index "1". The following image depicts how it is done in the Data Services Wizard:


Query UDTs via OUT Parameters of a Stored Procedure

It is possible to retrieve the values of UDTs via the OUT parameters defined in stored procedures. The user should define an input mapping as an OUT parameter as well as an output mappings, in order to actually retrieve the values of the UDT attributes.

Shown below is an example of how we can define the Input mapping in order to register an OUT parameter to be able to retrieve the value of a sample UDT called "PERSON_T".

  • No labels