To explain further, I have JAXB generated classes that make up the request for my web service. Inside some of these classes are xs:IDREF type attributes, the XML schema defines the object similar to this (only showing the relevant attributes)...
...which ends up looking like this in Java...
That's nothing too out of the ordinary and very valid to have. So now I added a SOAPHandler to the web service like this...
The defined handler chain has 1 handler that implements SOAPHandler
Now when I processed this unmarshalled object, I got a JAXBElement, then fetched its value object, which gave me the StrucDocRenderMultiMedia object in my case, then I printed out the array of referenced objects. This produced output similar to this...
That's all normal because my XML request did indeed have a valid object reference (not shown here).
Now when I removed the @HandlerChain annotation from the web service, the exact same request gave me this kind of output...
The object references were gone!
I tried to track this down to no avail, however what I did discover was this wasn't entirely dependent on having or not having the SOAPHandler. You could have the SOAPHandler and as long as you didn't call context.getMessage() method, the behaviour didn't change. In other words, this was the culprit...
I am guessing that when the SOAP Message is fetched from the context it does some kind of JAXB processing or initialisation that forces object references to resolve correctly, otherwise MOXy just returns an empty reference array.
In my case I actually didn't want these references to be resolved so I changed the generated JAXB classes to use @XmlTransient instead. That does not explain the strange behaviour that I saw, which I'd like to fully understand.
-i