You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Pieper, Aaron" <Pi...@Pragmatics.com> on 2009/03/19 15:31:06 UTC

CXF stub behavior - getters modify the collection properties.

I've encountered some strange behavior with CXF's stubs, and I'd like to
know if I should submit a tracker to capture this.

 

My application's WSDL has attribute properties which extend
"xsd:nmtokens". When generating Java stubs from the WSDL, CXF converts
these into List<String> properties. The getters are defined like this:

 

        public List<String> getDisCon () {

            if (disCon == null) {

                disCon = new ArrayList<String>();

            }

            return this.disCon;

        }

 

If the disCon field is null, CXF omits the attribute when converting the
property back into XML. However if the disCon field is an empty list,
CXF includes the attribute. Since the getDisCon method modifies the
disCon field when it's called, this means our code returns different XML
depending on whether or not we've called the getter. This behavior has
caused problems for my application, because I feed CXF's output through
an XSLT which gets confused if these fields are already populated.

 

- Aaron


Re: CXF stub behavior - getters modify the collection properties.

Posted by Daniel Kulp <dk...@apache.org>.
On Thu March 19 2009 10:31:06 am Pieper, Aaron wrote:
> I've encountered some strange behavior with CXF's stubs, and I'd like to
> know if I should submit a tracker to capture this.

This is actually not something CXF controls at all.   It's a JAXB thing.  You 
MAY be able to file a bug or similar with them:

https://jaxb.dev.java.net/

I'm really not sure what the spec says about this case.   Kind of bizzarre 
behavior though.

Dan

>
>
>
> My application's WSDL has attribute properties which extend
> "xsd:nmtokens". When generating Java stubs from the WSDL, CXF converts
> these into List<String> properties. The getters are defined like this:
>
>
>
>         public List<String> getDisCon () {
>
>             if (disCon == null) {
>
>                 disCon = new ArrayList<String>();
>
>             }
>
>             return this.disCon;
>
>         }
>
>
>
> If the disCon field is null, CXF omits the attribute when converting the
> property back into XML. However if the disCon field is an empty list,
> CXF includes the attribute. Since the getDisCon method modifies the
> disCon field when it's called, this means our code returns different XML
> depending on whether or not we've called the getter. This behavior has
> caused problems for my application, because I feed CXF's output through
> an XSLT which gets confused if these fields are already populated.
>
>
>
> - Aaron

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog