users@jersey.java.net

JAXB / Jersey client config question

From: Mark Petrovic <mark_at_petrovic.org>
Date: Thu, 3 Dec 2009 19:13:06 -0800

Good day.

I had a run-in today with a Jersey client that produced no namespace attribute in the XML serialized from a JAXB object. Turns out you can fix this by providing a JAXB context resolver to the ClientConfig for that Jersey client, where such a context resolver knows about the namespace of the serialized objects.

All this leaves me wondering how to build the namespace into the JAXB objects themselves so an overlooked ClientConfig context resolver does not produce what turns out to be under-formed XML. The maven plugin we're using for the XSD -> JAXB class generation produces the usual target/generated-sources folder, with a package-info.java file that contains the namespace spec. I don't know how this file is used, or by what. But since it exists I assume there might be a way to have the essence of its contents integrated into the JAXB classes themselves, making those classes aware of their namespace.

Hope this makes sense. Is there a way to make the JAXB classes aware of their namespace so the Jersey client doesn't need a special JAXB context resolver?

thx
Mark

--
Mark Petrovic
mark_at_petrovic.org
http://www.petrovic.org