I have the REST service method code below. When I check the status just
before the bytes are sent out, it is OK. But at the client side I get an
HTTP error of 500.
This is my client call:
InputStream iStream = res.accept(
MediaType.APPLICATION_OCTET_STREAM_TYPE).post(
InputStream.class, formData);
Setting the response when I am ready to send the bytes out seems to be
the problem.
DO you have an example of client/server byte stream?
Thanks.
REST service method:
@POST
@Produces("application/octet-stream")
@Consumes("application/x-www-form-urlencoded")
public Response getLogBundle(@FormParam("fromMillis") Long
inFromMillis,
@FormParam("toMillis") Long inToMillis,
@FormParam("fileList") String
inFileList) {
if ((inFromMillis == null) || (inToMillis == null) ||
StringUtils.isEmpty(inFileList)) {
throw new
RestApplicationException(Response.Status.BAD_REQUEST,
"Parameter fromMillis, toMillis, and/or fileList is
missing or is invalid.");
}
String[] files = inFileList.split(",");
Set<String> fileSet = new HashSet<String>(Arrays.asList(files));
String comment = "Log files corresponding to date range " +
DEFAULT_SDF.format(inFromMillis) + " to " +
DEFAULT_SDF.format(inToMillis);
Response resp;
ByteArrayOutputStream oStream = new ByteArrayOutputStream();
long checkSum = FileCompressionUtils.compressFiles(fileSet,
oStream, comment);
if (checkSum == 0L) {
resp = Response.noContent().build();
} else {
resp = Response.ok(oStream,
MediaType.APPLICATION_OCTET_STREAM_TYPE).build();
}
return resp;
}
-------------------------
Gisella Saavedra
Sr. Software Engineer
gsaavedra_at_zebra.com <mailto:gsaavedra_at_zebra.com>
1000 Broadway, Suite 150, Oakland, CA 94607 | T+1 510 267 5123 T
Main+1 510 267 5000 F+1 510 267 5100 |
http://www.zebra.com/zes
<
http://www.zebra.com/zes>