After upgrading to SmartGWT 13, we no longer receive an error response via the API using JSON.
This is verifiable in our software and in the latest built-in-ds.
To make it easier to understand, I'll use the built-in-ds example.
I have created the following class as a DMI, including the error return as specified in the Quickstart Guide, among other things:
I have also extended animals.ds.xml as follows:
and finally adapted the web.xml and the RESTHandler servlet as follows:
My following query with XML:
returns the following result:
in JSON:
the error message is missing here, only the status was apparently adopted:
We would be grateful for any help.
This is verifiable in our software and in the latest built-in-ds.
To make it easier to understand, I'll use the built-in-ds example.
I have created the following class as a DMI, including the error return as specified in the Quickstart Guide, among other things:
Code:
package com.smartgwt.sample.server;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;
public class AnimalsDMI {
public DSResponse fetchAnimals(DSRequest dsRequest) throws Exception {
if(dsRequest.getFieldValue("id") == null || dsRequest.getFieldValue("id").toString().equals("")) {
DSResponse dsResponse = new DSResponse();
dsResponse.setStatus(DSResponse.STATUS_VALIDATION_ERROR);
dsResponse.addError("commonName", "Error, commonName-Field not set!");
return dsResponse;
}
return dsRequest.execute();
}
}
I have also extended animals.ds.xml as follows:
Code:
<operationBindings>
<operationBinding operationType="fetch">
<serverObject className="com.smartgwt.sample.server.AnimalsDMI" methodName="fetchAnimals"/>
</operationBinding>
</operationBindings>
and finally adapted the web.xml and the RESTHandler servlet as follows:
Code:
<servlet>
<servlet-name>RESTHandler</servlet-name>
<servlet-class>com.isomorphic.servlet.RESTHandler</servlet-class>
<init-param>
<param-name>defaultDataFormat</param-name>
<param-value>xml</param-value>
</init-param>
<init-param>
<param-name>dynamicDataFormatParamName</param-name>
<param-value>theDataFormat</param-value>
</init-param>
<init-param>
<param-name>wrapJSONResponses</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
My following query with XML:
Code:
curl --location 'http://127.0.0.1:8888/builtinds/sc/RESTHandler?theDataFormat=xml' \ --header 'Content-Type: application/xml' \ --header 'Cookie: isc_cState="ready"' \ --data '<?xml version="1.0" encoding="UTF-8"?> <root> <data /> <dataSource>animals</dataSource> <operationType>fetch</operationType> </root>'
returns the following result:
Code:
<?xml version="1.0"?>
<response>
<queueStatus>-1</queueStatus>
<status>-4</status>
<errors>
<commonName>
<errorMessage>Error, commonName-Field not set!</errorMessage>
</commonName>
</errors>
<data></data>
</response>
in JSON:
Code:
curl --location 'http://127.0.0.1:8888/builtinds/sc/RESTHandler?theDataFormat=json' \
--header 'Content-Type: application/json' \
--header 'Cookie: isc_cState="ready"' \
--data '{
"data":{
},
"dataSource":"animals",
"operationType":"fetch",
"operationId": "fetchAnimals"
}'
the error message is missing here, only the status was apparently adopted:
Code:
{
"response": {
"queueStatus": -1,
"status": -4,
"startRow": null,
"endRow": null,
"totalRows": null,
"data": null
}
}
We would be grateful for any help.
Comment