cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kaleb Walton <kdwal...@us.ibm.com>
Subject Re: Empty List's not being marshaled?
Date Wed, 03 Oct 2007 10:09:33 GMT

Thank you!

Do you know why that is the case? Maybe because since it's empty they
figured there shouldn't be any wasted space in the XML doc?

It's a pain for my consumers to have to check for the existence of a
variable before trying to parse it out - not the end of the world but it
adds somewhat redundant code.


Regards,
Kaleb


|------------>
| From:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Daniel Kulp <dkulp@apache.org>                                                  
                                                                 |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |cxf-user@incubator.apache.org                                                         
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Cc:        |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Kaleb Walton/Southfield/IBM@IBMUS                                                     
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |10/02/2007 05:55 PM                                                                   
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  >--------------------------------------------------------------------------------------------------------------------------------------------------|
  |Re: Empty List's not being marshaled?                                                 
                                                           |
  >--------------------------------------------------------------------------------------------------------------------------------------------------|





On Tuesday 02 October 2007, Kaleb Walton wrote:
> I'm using the simple server configured via Spring. When an object
> contains an empty list (not null) my response does not return it as an
> empty list - it just excludes the property from the response. Is there
> any way to force it to include the property?

I'd probably have to see both the schema and the soap message.   Most
likely, the answer is no without creating a holder bean to hold the
list.

For the most part, when we see something like List<String>, we just
create:
<element name="foo" type="string" maxOccurs="unbounded" nillable="true"/>

In that case, if the list is empty (or even if the list is null), nothing
representing the list will appear on the wire.   That is how the JAXB
spec calls for it to be done.  If you want something always on the wire,
the schema would have to be something like:
<element name="fooList">
<complexType>
<sequence>
<element name="foo" type="string" maxOccurs="unbounded" nillable="true"/>
</sequence>
<complexType>
</element>

and a "FooList" class would be created to hold the List<String>.

--
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message