Hi Scott,
Yes, it's the unwrap-then-transform to JAXB that is the problem.
You are adding two attributes, however once you are finished with them
they should be removed before the call to unmarshaller.unmarshal(reader,
type) in OMElement2JAXB.transform().

The two attributes that you are adding to the node are causing
XsiNilLoader (as detailed in the original mail) to return
StructureLoader instead of Discarder.INSTANCE.

This means that when the webservice method is called it will get an
empty object instead of null.
This renders any check for (arg == null) in the method to function
incorrectly (as the argument that was passed with 'XSI:null=true' if not
null).

Padraig



-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Scott Kurz
Sent: 31 March 2011 20:37
To: [email protected]
Subject: Re: JaxB Unmarshaller not working properly for xsi:nil

Hi Padraig,


On Thu, Mar 31, 2011 at 1:38 PM, Padraig Myers
<[email protected]> wrote:

> It transforms each of the objects adding xsi:type if it is a complex
object,
> such that privacyList in the above example becomes:
>
> <privacyList
xmlns:_typens_="http://business.management.image.company.com/";
> xsi:nil="true" xsi:type="_typens_:privacyListDTO"></privacyList>


Just want to make sure I'm following.   It sounds like you're talking
about the path in which we unwrap-then-transform to JAXB, right?
I know in this path the OMElementWrapperHandler will add the xsi:type
to each wrapper child to facilitate the transform from OMElement child
to JAXB child.

Does that sound like what you are talking about?

If so, one thing worth considering is that you should be able to
bypass this path by using a schema-valid payload, if this is an option
for you.    With a schema-valid payload, we will typically do a
wrapper->wrapper transform from XML->JAXB, whereas with a non-valid
payload we will go down this child->child transform path.

If that's not relevant or if somehow the problem still exists, have
you looked at using  @XmlJavaTypeAdapter
to customize unmarshalling.   I don't have any particularly good doc
to point to, but there is some info out there on the subject, and
there's always the Java doc.

Hope that helps,
Scott

Reply via email to