restwso2wso2-data-services-server

How to return more than 1 record on REST service with WSO2 DSS?


I'm using WSO2 DSS with MySQL database. If I request just 1 record from database, it works correctly. But when I try to select more than 1 registry in a REST service, it doesn't works. The error is:

{
    "Fault": {
    "faultcode": "soapenv:Server"
    "faultstring": "Error while writing to the output stream using JsonWriter"
    "detail": ""
    }-
}

My data service:

<data name="item" transports="http https local">
<config enableOData="false" id="default">
  <property name="carbon_datasource_name">mysql</property>
</config>
<query id="selectActiveItems" useConfig="default">
  <sql>SELECT descricao FROM ITEM WHERE ativo = true and id_responsavel = ?</sql>
  <result escapeNonPrintableChar="true" outputType="json">{  "_item": {  "descricao":$descricao}}</result>
  <param name="id_responsavel" ordinal="1" sqlType="INTEGER"/>
 </query>
  <resource method="POST" path="selectActiveItems">
   <call-query href="selectActiveItems">
     <with-param name="id_responsavel" query-param="id_responsavel"/>
    </call-query>
   </resource>
</data>

There is any property to set that I didn't set?


Solution

  • The correct output to response more than 1 record from database is:

    <result escapeNonPrintableChar="true" outputType="json">
      {"_itens":{"item": [ {"nome":$nome,"descricao":$descricao} ] }}
    </result>