[Download] | [Documentation Home] | [Release Note]
When using data services, the user may come across the need to transfer binary data from/to the server. This is handled in WSO2 Data Services Server using Base64 encoding, where when sending binary data, it should be encoded in Base64 format and sent. Also when receiving data, to get the original binary data back, the receiving character data must be Base64 decoded to get the binary data.
In the input mappings section, when adding a new entry, the "SQL Type" should be selected as "BINARY". This step is showed in Figure 1.
Figure 1: Adding binary types to input mappings.
When defining the result of a data service, in order to declare there is a binary value is expected, we have to add a suitable output mappings entry. In the output mappings, the "Schema Type" should be selected as "xs:base64Binary", as shown below in Figure 2.
Figure 2: Adding binary types to output mappings.
When using code generated clients, the encoding/decoding of Base64 data will not have to be explicitely done by the user, since the existance of the binary data is mentioned in the WSDL. For example, in Axis2 code generated stubs, the binary types are handled using the DataHandler class.
For a demonstration of the usage of binary data types, refer to the File App Sample.