This really is a "JAXB" issue and not specific to CXF. Basically, by default, when JAXB marshals something, it sticks all the namespaces it knows about out in the root element of what it's marshalling as it doesn't know which it will need ahead of time, so it does all of them.
The only way I know around it is to write your own com.sun.xml.bind.marshaller.NamespacePrefixMapper and override the methods: String[] getPreDeclaredNamespaceUris() String[] getPreDeclaredNamespaceUris2() to just declare the ones you think are needed up front and then register that with the CXF JAXB Databinding. Dan On Mon February 23 2009 3:28:55 am Sky-Tiger wrote: > Hi, > Recently i test my system which used CXF2.1.2 as soap engine. I found > the soap messages that generated were very verbose. Some namespaces > declared more than once, some were not used at all but still included in > soap message, like this: > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Header> > <header xmlns:ns40="http://www.tmforum.org/mtop/nra/xsd/pg/v1" > xmlns:ns39="http://www.tmforum.org/mtop/nrf/xsd/ftp/v1" > xmlns:ns38="http://www.tmforum.org/mtop/nrf/xsd/eq/v1" > xmlns:ns37="http://www.tmforum.org/mtop/nrf/xsd/rs/v1" > xmlns:ns36="http://www.tmforum.org/mtop/nrf/xsd/mlsn/v1" > xmlns:ns35="http://www.tmforum.org/mtop/nrf/xsd/mfd/v1" > xmlns:ns34="http://www.tmforum.org/mtop/nrf/xsd/ptp/v1" > xmlns:ns33="http://www.tmforum.org/mtop/nrf/xsd/fdfr/v1" > xmlns:ns32="http://www.tmforum.org/mtop/nra/xsd/pgp/v1" > xmlns:ns31="http://www.tmforum.org/mtop/nra/xsd/epg/v1" > xmlns:ns30="http://www.tmforum.org/mtop/nrf/xsd/gtp/v1" > xmlns:ns29="http://www.tmforum.org/mtop/nrf/xsd/tpdata/v1" > xmlns:ns28="http://www.tmforum.org/mtop/nrf/xsd/snc/v1" > xmlns:ns27="http://www.tmforum.org/mtop/nrf/xsd/tppool/v1" > xmlns:ns26="http://www.tmforum.org/mtop/nrf/xsd/ctp/v1" > xmlns:ns25="http://www.tmforum.org/mtop/nrf/xsd/os/v1" > xmlns:ns24="http://www.tmforum.org/mtop/nrf/xsd/eh/v1" > xmlns:ns23="http://www.tmforum.org/mtop/nrf/xsd/tl/v1" > xmlns:ns22="http://www.tmforum.org/mtop/nrf/xsd/fd/v1" > xmlns:ns21="http://www.tmforum.org/mtop/nrf/xsd/tmd/v1" > xmlns:ns20="http://www.tmforum.org/mtop/nrb/xsd/lp/v1" > xmlns:ns19="http://www.tmforum.org/mtop/nrb/xsd/lay/v1" > xmlns:ns18="http://www.tmforum.org/mtop/nrf/xsd/me/v1" > xmlns:ns17="http://www.tmforum.org/mtop/nrb/xsd/cri/v1" > xmlns:ns16="http://www.tmforum.org/mtop/fmw/xsd/coi/v1" > xmlns:ns15="http://www.tmforum.org/mtop/mri/xsd/rir/v1" > xmlns:ns14="http://www.tmforum.org/mtop/mri/xsd/tlr/v1" > xmlns:ns13="http://www.tmforum.org/mtop/mri/xsd/mdr/v1" > xmlns:ns12="http://www.tmforum.org/mtop/mri/xsd/tpr/v1" > xmlns:ns11="http://www.tmforum.org/mtop/rtm/xsd/ar/v1" > xmlns:ns10="http://www.tmforum.org/mtop/rtm/xsd/ah/v1" > xmlns:ns9="http://www.tmforum.org/mtop/mri/xsd/mer/v1" > xmlns:ns8="http://www.tmforum.org/mtop/mri/xsd/osr/v1" > xmlns:ns7="http://www.tmforum.org/mtop/mri/xsd/rs/v1" > xmlns:ns6="http://www.tmforum.org/mtop/fmw/xsd/notmsg/v1" > xmlns:ns5="http://www.tmforum.org/mtop/mri/xsd/eir/v1" > xmlns:ns4="http://www.tmforum.org/mtop/fmw/xsd/msg/v1" > xmlns:ns3="http://www.tmforum.org/mtop/fmw/xsd/nam/v1" > xmlns:ns2="http://www.tmforum.org/mtop/fmw/xsd/gen/v1" > xmlns="http://www.tmforum.org/mtop/fmw/xsd/hdr/v1"> > <activityName>?</activityName> > <msgName>?</msgName> > <msgType>REQUEST</msgType> > <senderURI>?</senderURI> > <destinationURI>?</destinationURI> > <replyToURI>?</replyToURI> > <originatorURI>?</originatorURI> > <failureReplytoURI>?</failureReplytoURI> > <activityStatus qualifier="?"/> > <correlationId>?</correlationId> > <security>?</security> > <securityType>?</securityType> > <priority>?</priority> > <msgSpecificProperties> > <property> > <propName>?</propName> > <propValue>?</propValue> > </property> > </msgSpecificProperties> > <communicationPattern>SimpleResponse</communicationPattern> > <communicationStyle>RPC</communicationStyle> > <batchSequenceEndOfReply>false</batchSequenceEndOfReply> > <iteratorReferenceURI>?</iteratorReferenceURI> > <fileLocationURI>?</fileLocationURI> > <compressionType extension="?"/> > <packingType extension="?"/> > <vendorExtensions/> > </header> -- Daniel Kulp [email protected] http://www.dankulp.com/blog
