Hi,

Need help in regards to a problem with how Tuscany handles xsi:nil when
unmarshalling request attributes.

If the request contains a complex object, for example

<assignImageToUser xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>

  <imageId>0</imageId>

  <userId>2</userId>

  <privacy>1</privacy>

  <privacyList xsi:nil="true"></privacyList>

</assignImageToUser>

 

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>

 

However because of a fix put into the JRE in
"com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.selectLo
ader(UnmarshallingContext.State state, TagName ea)" it creates the
object if the number of attributes is more than 1.

The offending piece of code is:

boolean hasOtherAttributes = (ea.atts.getLength() - 1) > 0;

      // see issues 6759703 and 565 - need to preserve attributes even
if the element is nil; only when the type is stored in JAXBElement

      if (!(hasOtherAttributes && (state.prev.target instanceof
JAXBElement))) {

          return Discarder.INSTANCE;

      }

 

What the above code means is that when the assignImageToUser method is
called it will construct the privacy list argument instead of passing it
in as null.

 

Is there some way of creating our own unmarshaller that wraps the
default unmarshaller, so that we can remove the xsi:type before it calls
XsiNilLoader.selectLoader()?

The xsi:type is no longer needed at this stage because the type object
has already been constructed.

 

Thanks, 

Padraig

 

 

 

Reply via email to