Setting that flag on the output of  StaxOutInterceptor.getXMLOutputFactory 
with previous versions of CXF was probably a bad thing.   Under normal 
circumstances, that XMLOutputFactory would have been shared all over the place 
so setting properties on it would affect things other than the service.

The BEST option is to create your own XMLOutputFactory, set it any way you 
want/need with setting properties and such, and then setting it on the message 
or endpoint with the key:
"javax.xml.stream.XMLOutputFactory"


You may even be able to do it completely in Spring config and not deal with 
the interceptors at all.   Create a new instance of WstxOutputFactory and set 
the P_AUTOMATIC_EMPTY_ELEMENTS property and such and then configure that into 
the jaxws:endpoint properties with the above key.

Dan



On Wed August 19 2009 5:08:33 am Sergey Pulyaev INTEGO wrote:
> Hi all,
>
> After switching from 2.0.9 to 2.2.3 i found that StaxOutInterceptor have
> changes it's behaviour.
>
> I have a problem with XMLStreamWriter in 2.0.9 - if function returns
> empty array - it will be changed to a null -
> for example:
> <getArrayResult>
> </getArrayResult>
>     which mean new ArrayList() on client
>
> will be changed to
> <getArrayResult />
>
> That means on client null.
>
> I have fixed this by creating new interceptor before StaxOutInterceptor
> and set "auto empty elements" property of xml writer to false
>         XMLOutputFactory outputFactory =
> StaxOutInterceptor.getXMLOutputFactory(message);
>
> if(WstxOutputFactory.class.isAssignableFrom(outputFactory.getClass())){
>             WstxOutputFactory of = (WstxOutputFactory)outputFactory;
>
> of.getConfig().setProperty(XMLOutputFactory2.P_AUTOMATIC_EMPTY_ELEMENTS,
> false);
>         }
>
> Now StaxOutInterceptor.getXMLOutputFactory always returns NULL - so i
> have no way to specify this flag anymore.
>
> How can i setup XMLStreamWriter to
>
> AUTOMATIC_EMPTY_ELEMENTS = OFF ?
>
> Best regards,
>     Sergey
>
> --------
> This data is for general information only and shall not be used to produce
> documents of any kind without same being submitted to, reviewed by, and
> approved by Intego in writing. All data is subject to change. User assumes
> all liability relating to the use of this data and agrees to release,
> indemnify, and hold harmless Intego from any and all claims relating said
> use. User is responsible to check for any viruses before use.

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

Reply via email to