On Oct 27, 2009, at 3:50 PM, Gallagher,Patrick wrote:
> Thanks Paul. I have also come across another issue while working
> through this one. I created an issue [1] that illustrates this.
> I’m responding on this thread due to the issue coming to life while
> troubleshooting my initial problem and for completeness.
>
> 1. https://jersey.dev.java.net/issues/show_bug.cgi?id=400
>
Thanks. Jakub can confirm but i think you will need to add a
ContextResolver for namespaces support.
For example, create the following class:
@Provider
public static class Resolver implements
ContextResolver<JAXBContext> {
private final JSONJAXBContext context;
public Resolver() throws Exception {
this.context = new
JSONJAXBContext(JSONConfiguration.natural().build(), "json.junit");
}
public JAXBContext getContext(Class<?> type) {
if (type == ReqType.class) {
return context;
}
return null;
}
}
make sure it is registered on the server side and also register it on
the client side:
ClientConfig cc = new DefaultClientConfig();
cc.getClasses().add(Resolver.class);
Client c = Client.create(cc);
and then your test will pass.
The above uses the JSON JAXB "natural" convention.
By default Jersey uses it's mapped convention and i think when
namespaces are required with the mapped convention you need to provide
a mapping:
https://jersey.dev.java.net/nonav/documentation/1.1.2-ea/user-guide.html
#json.jaxb.jettison.mapped.ns.def
Paul.
>
>
> Content-type: multipart/alternative;
> boundary="Boundary_(ID_2r55hb9wHFNXc7TIcUUnzQ)"
> Date: Mon, 26 Oct 2009 16:26:22 +0100
> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> Subject: [Jersey] jersey-json @Consume POST
>
> On Oct 26, 2009, at 4:23 PM, Paul Sandoz wrote:
> >
> > OK. I suspect that because it was annotated with @XmlRootElement and
> > @XmlType the old JSON/JAXB stuff got confused.
>
>
> > In any case we should add a test case for this even though it is not
> > working so we do not regress
> > in the future.
>
> I mean to say "even though it is working...".
>
> Paul
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are
> from Cerner Corporation and are intended only for the addressee. The
> information contained in this message is confidential and may
> constitute inside or non-public information under international,
> federal, or state securities laws. Unauthorized forwarding,
> printing, copying, distribution, or use of such information is
> strictly prohibited and may be unlawful. If you are not the
> addressee, please promptly delete this message and notify the sender
> of the delivery error by e-mail or you may call Cerner's corporate
> offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.