I am trying to write a web application that uses REST webservices to handle post actions. The post pushes a message to the server then I need to start sending back periodic responses (occasional messages with a regular heartbeat message).
Please note I am fairly new to REST webservices so feel free to correct me if I'm barking up the wrong tree!
This is to interface with a system that I have no control over so I can't modify the HTTP POST.
e.g.
POST: Hello
Response: World
Response: Heartbeat
-- wait 60 secs --
Response: Heartbeat
-- wait 60 secs --
Response: Heartbeat
-- wait 60 secs --
My understanding is that this same mechanism is used for sending MJPEG video over HTTP.
I have found several examples of POST services consuming multipart form messages but nothing on how to response with multipart.
The stub code that I am starting from looks like this:
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.core.Context;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
--- ommitted code ---
@Context
private UriInfo context;
--- ommitted code ---
@POST
@Produces("multipart/mixed")
@Consumes(MediaType.TEXT_XML)
@Path("/{id}")
public Response doPost(String msg, @PathParam("id") String id) throws IOException
{
// How do I do this as a multipart response?!
return Response.status(Response.Status.OK).entity("").build();
}
Hopefully someone can help as I have found very little/nothing of use anywhere on the internet!