I need to return a list of objects from a restful webservice. each object is a row of database table data.
This is my restfulwebservice
@GET
@Consumes("text/html")
@Produces(MediaType.MULTIPART_FORM_DATA)
public ArrayList<FetchDatabase> fetchFromDatabse(){
return new CouponSetup().fetchFromDatabse();
}
FetchDatabase is a bean. I got the required resultset size after the fetch
when i try to call this webservice am getting an error Status 500 Internal server error and the following in the console
A message body writer for Java class java.util.ArrayList, and Java type java.util.Collection, and MIME media type multipart/formdata was not found
I have tried commenting the @produces annotation still the same error with MIME media type application/octet-stream
I have read that we need to convert the list to XML or json and retrieve it later
Is there any alternate way?If not can u help me parsing the object into XML/JSON and retrieving later in JAVASCRIPT
Can anyone help in a method to iterate through the object here JSONArray and form a table from it
I am using Tomcat 7.0.22 server and jersey RS 1.11
Tried using the above method, but converting the JSONArray back to list was tiresome. so i converted each list object to a json and added to the JSONArray and returned the JSONarray. In the client side, i iterated through the Array and retrieved details from each JSON object.