|
From: Adam B. <ab...@lb...> - 2010-03-23 19:49:03
|
I am wrestling with marshalling a simple ArrayList<String> collection.
In the case of XML, I am trying to obtain something like the following:
<status-values>
<status>some status string</status>
<status>some other status string</status>
</status-values>
Currently, I have the following interface:
@Path("/")
public interface RestService
{
@GET
@Path("status/list")
@Produces("text/xml"), "application/xml", "application/json", "application/x-yaml"})
@Wrapped(element = "status-values")
List<String> getStatusValuesList();
@GET
@Path("status/response")
@Produces({"text/xml", "application/xml", "application/json", "application/x-yaml"})
@Wrapped(element = "status-values")
Response getStatusValuesResponse();
}
and I have tried the following impls:
public class RestServiceImpl implements RestService
{
@Override
public List<String> getStatusValuesList()
{
return dataProvider.getStatusValues();
}
@Override
public Response getStatusValuesResponse()
{
List<String> statuses = dataProvider.getStatusValues();
return Response.ok(new GenericEntity<List<String>>(statuses){}).build();
}
}
Each approach throws:
org.jboss.resteasy.core.NoMessageBodyWriterFoundFailure: Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/xml
The exception is thrown because I am unsure how to specify the ArrayList values are Strings (not xml fragments) and should be wrapped in <status/> tags.
Given the quality of this API I think I am missing something obvious/simple. Any direction would be much appreciated. I'm using version 1.2.1.GA.
--adam
|