users@jersey.java.net

RE: [Jersey] Response into UTF-16 encoding

From: Patrick Sauts <patrick.viadeo_at_gmail.com>
Date: Tue, 13 Apr 2010 11:55:37 +0200

The declaration on the resource is @Produces( { MediaType.APPLICATION_JSON,
MediaType.APPLICATION_XML, "specialxml/xml; charset=UTF-16" })


In facts we change mediatype from "specialxml/mxl; charset=UTF-16" to
"application/xml; charset=UTF-16" in the writeTo method and that made it
work fine.
If we leave it to "specialxml/mxl; charset=UTF-16" we have <?xml
version="1.0" encoding="UTF-8"> on top of the xml response.

But maybe we were doing wrong at the first place.

Pat.

-----Message d'origine-----
De : Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
Envoyé : mardi 13 avril 2010 11:01
À : users_at_jersey.dev.java.net
Cc : Guillaume Hiron
Objet : Re: [Jersey] Response into UTF-16 encoding


On Apr 13, 2010, at 10:28 AM, Patrick Sauts wrote:

> Hi Paul,
>
> Thanks to the code you sent us we’ve found a solution,
>
> @Produces("specialxlm/xml; charset=UTF-16")
> @Provider
> public class SpecialXMLProvider extends JSONWithPaddingProvider {
> …
> @Override
> public void writeTo(…){
> …
> super.writeTo(t, type, genericType, annotations,
> new MediaType("application", "xml", mediaType.getParameters()),
> httpHeaders, entityStream);
>
> …
> And it works fine that way.
>

OK.

I am still confused as to why the XML document, in your first email,
was encoded in UTF-16 and not UTF-8.

Are you declaring an @Produces method on the resource method that
returns the JSON with padding?

If you have the time to create a simple test case i can investigate
further, as it seems the work around you have implemented should not
be required i.e. it should just work as you expected.

Paul.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net

Ce message entrant est certifié sans virus connu.
Analyse effectuée par AVG - www.avg.fr
Version: 9.0.801 / Base de données virale: 271.1.1/2805 - Date: 04/12/10
20:32:00