users@jersey.java.net

[Jersey] Multipart with unusual mediaType

From: Norbert Kiesel <nkiesel_at_MetricStream.com>
Date: Sat, 14 Feb 2015 00:54:48 +0000

Hi,


I try to write a client (with Jersey 2.16) that receives and processes a multipart response from a server. However, the server sends "application/x-bulk-multipart+xml; version=1.0" as mediaType, and the entity has 2 body parts: a "application/atom+xml; type=feed" and another application mediaType.


My first attempt was to use `MultiPart mp = response.readEntity(MultiPart.class);` which compiled but failed during runtime because of a media type mismatch. Then I tried to create a derived class from MultiPart, but this fails as well because MultiPart.setMediaType rejects any media types that are not "multipart" (see line 122 in [1] for details).


Any ideas how to proceed?


[1]: https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java

[https://avatars0.githubusercontent.com/u/399710?v=3&s=400]<https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java>

jersey/MultiPart.java at master · jersey/jersey · GitHub
This is an active mirror of Jersey 2.x workspace from http://jersey.java.net. Any changes made here are automatically propagated to java.net and vice versa. Forks and pull requests are welcome!
Read more...<https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java>


[https://avatars0.githubusercontent.com/u/399710?v=3&s=400]<https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java>

jersey/MultiPart.java at master · jersey/jersey · GitHub
This is an active mirror of Jersey 2.x workspace from http://jersey.java.net. Any changes made here are automatically propagated to java.net and vice versa. Forks and pull requests are welcome!
Read more...<https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java>


</nk>

---
Norbert Kiesel
Systems Architect | Engineering
MetricStream
2600 E. Bayshore Road | Palo Alto, CA - 94303
+1-650-620-2954 | nkiesel_at_metricstream.com | www.metricstream.com
Confidentiality Notice:This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited