I am using Wso2 DSS and building RESTful webservices from an oracle DB and trying to return custom error messages in case no records found or invoked using invalid parameters. And I also want to control the HTTP return code for these error responses.
For example. Lets say there is a webservice: /getemployee/{empno} that returns employee details in JSON/XML format.
If I call getemployee with an empno that doesn't exists in the DB then
I want the response to be like something similar to below
<Error><Error_code>No employee found </Error_code></Error>
It should not have the normal employee details message structure that would go as response when an employee is found. At the moment if record is not found by the underlying query DSS just returns empty message with just root element.
- The HTTP return code for this response should be 404 as opposed to the success code 200. By default all responses get HTTP return code 200 in DSS.
Is this possible at all just by using DSS?
Appreciate your help