0
在新泽西我可以发送多部分/混合的数据是这样的:泽西读取嵌套多部分(多部分/混合)
MultiPart multipartWrapper = new MultiPart(MultiPartMediaTypes.MULTIPART_MIXED_TYPE);
for (IMessageContainer msgCont : input.getMessages()) {
MultiPart m = new MultiPart(MultiPartMediaTypes.MULTIPART_MIXED_TYPE)
.bodyPart(
new BodyPart(msgCont.getDescription(), MediaType.APPLICATION_JSON_TYPE))
.bodyPart(
new BodyPart(msgCont.getDetails(), MediaType.APPLICATION_OCTET_STREAM_TYPE));
//nest the new multipart into a bodypart within the root multipart
multipartWrapper.bodyPart(new BodyPart(m, MultiPartMediaTypes.MULTIPART_MIXED_TYPE));
}
}
此包络的multipart /混合现在可以通过线路来发送作为响应的一部分。在接收方我们可以做
MultiPart entity = response.readEntity(MultiPart.class);
List<BodyPart> bodyParts = entity.getBodyParts();
List<IMessageWrapper> rslt = new ArrayList<>();
for(BodyPart bp : bodyParts) {
//how do we get the wrapped Multipart here, so we can
//get into its BodyParts?
}
我觉得我缺少一些东西。我们怎样才能到达包装在BodyPart中的Multipart?在检查BodyPart时,它只是包含org.jvnet.mimepull.MimePart。