Hello,
I have a JAX-RS service which one of endpoints consumes a multipart containg
a list of attachments. The first attachment is a JSON object, the next ones
are input streams. Here is the signature:
@POST
@Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_JSON,
"multipart/mixed" })
@Path("createTransaction")
public Response myEndPoint (@Multipart(value = "context", type =
MediaType.APPLICATION_JSON)MyContext ctx, MultipartBody mb) throws
QuickSignException
So, the idea is to have a first part of type "application/json", followed by
a certain number of parts having input streams to PDF files.
The client calling the end-point looks as follows:
List<Attachment> attachments = new ArrayList<Attachment>();
attachments.add(new Attachment("context", MediaType.APPLICATION_JSON,
new MyContext()));
attachments.add((new Attachment ("contracts",
MediaType.MULTIPART_FORM_DATA, new FileInputStream (new File
("test.pdf")))));
Response resp = client.target(new
URI("http://localhost:9082/qs/services/api/createTransaction")).request().post(Entity.entity(new
MultipartBody(attachments), MediaType.MULTIPART_FORM_DATA_TYPE));
assertEquals (200, resp.getStatus());
And the assertions fails as the service responds with HTTP 415.
So, my questions are:
1. Is that the right way to accomplish what I need, aka passing a JSON
object and a variable number of input files in a multipart ?
2. If this is the right way to do that, why do I get HTTP 415 and how to
correct that ?
Many thanks in advance,
Nicolas
--
View this message in context:
http://cxf.547215.n5.nabble.com/HTTP-415-raised-by-JAX-RS-service-consuming-multipart-tp5780784.html
Sent from the cxf-user mailing list archive at Nabble.com.