users@jersey.java.net

[Jersey] Re: Multipart with unusual mediaType

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 20 Feb 2015 12:32:01 +0100

It seems we only support handling “multipart/*” media types at the moment. Please, file a new enhancement request.
As a workaround, you can implement a custom ClientResponseFilter <https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/client/ClientResponseFilter.html> or ReaderInterceptor <https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs/javax/ws/rs/ext/ReaderInterceptor.html> that will “fix” the media type to something Jersey will not complain about…

Cheers,
Marek


> On 14 Feb 2015, at 01:54, Norbert Kiesel <nkiesel_at_MetricStream.com> wrote:
>
> 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://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/MultiPart.java>
> <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 <http://jersey.java.net/>. Any changes made here are automatically propagated to java.net <http://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://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 <http://jersey.java.net/>. Any changes made here are automatically propagated to java.net <http://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@metricstream.com <mailto:nkiesel@metricstream.com> | www.metricstream.com <http://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