After doing some investigation and prototyping, I have been thinking that
if there is not an annotation based way of doing this, then writing an
interceptor for the pre marshal phase and modifying the values of the
object to be marshalled there. This requires I have all the fields in the
object to be marshalled as strings. This just seems unnecessary, surely
there has to be a better way of doing this...
Also, to get the object that will be marshalled from the Message object,
it seems I have to do :
public void handleMessage(Message message) throws Fault {
List<Object> responseObjects = message.getContent(List.class);
Object responseObject = responseObjects.get(0);
}
Is this correct or is there an easier way of doing this?
Will the responseObjects list I get back always contain one element?
-----Original Message-----
From: Mustafa Sezgin [mailto:[email protected]]
Sent: Thursday, 3 December 2009 2:50 PM
To: [email protected]
Subject: Marshalling null value fields
Hi all,
I have some beans in a rest service which marshalled and sent back to the
end user. However sometimes certain fields in the bean may not have values
and as a result, the XML that gets produced can sometimes omit these
fields. We want the responses to always be consistent, so even if a field
does not have a value, then an empty tag should be returned. Looking at
the XMLElement and XMLAttribute annotations, there doesn't seem to be
anything which helps with this. I don't want to have to go back and
manually set an empty string value to these fields. And some of these
fields are Date or Integer objects so I cant set an empty value to these
fields, like I can with a string.
Any ideas on how to get around this problem would be appreciated..
Thanks