We actually looked into the JAXB code yesterday and it doesn't look like there 
is a way to do it.  :-(

The NamespacePrefixMapper thing can be used to ADD extra namespaces to the 
root, but I'm not really sure why you would do that.   The code in jaxb always 
adds the namespaces it knows about first, then all the namespaces in the 
NamespacePrefixMapper.   Thus, this is a JAXB thing, not really a CXF thing.   
If JAXB can provide some method of controlling this, we could wire it into 
CXF, but at this point, I don't see a way from JAXB to change this.

Dan



On Tuesday 09 November 2010 11:32:51 am KARR, DAVID (ATTSI) wrote:
> > -----Original Message-----
> > From: Daniel Kulp [mailto:[email protected]]
> > Sent: Monday, November 08, 2010 12:32 PM
> > To: [email protected]
> > Cc: KARR, DAVID (ATTSI)
> > Subject: Re: Envelope has xmlns attributes for EVERY schema defined in
> > WSDL, even if not referenced
> > 
> > 
> > This is how JAXB outputs things by default.   It pretty much always
> > outputs
> > all the namespaces that it knows about at the "root" of the document
> > that it
> > is writing.
> > 
> > You can control it somewhat by createing a
> > com.sun.xml.bind.marshaller.NamespacePrefixMapper and registering that
> > with
> > the JAXBDataBinding in CXF.   It would probably return an empty list
> > from
> > getPreDeclaredNamespaceUris and getPreDeclaredNamespaceUris2.
> 
> Could you be more specific?  I assume you mean to define a class that
> extends NamespacePrefixMapper.  The default implementation already
> returns an empty string from "getPreDeclaredNamespaceUris()",
> "getPreDeclaredNamespaceUris2()", and "getContextualNamespaceDecls()".
> What would I put in the "getPreferredPrefix()" method?
> 
> How do I "register" this instance in CXF?
> 
> What exactly will be the result of adding this?
> 
> > On Friday 05 November 2010 4:41:47 pm KARR, DAVID (ATTSI) wrote:
> > > I have an existing service client that uses JAXB, with an ad hoc
> 
> Soap
> 
> > > infrastructure.  When I marshal the envelope in the existing code, I
> > 
> > get
> > 
> > > xmlns attributes for all the namespaces that are actually used in
> 
> the
> 
> > > envelope, which isn't many.  It only produces one application-
> > 
> > specific
> > 
> > > one.
> > > 
> > > Our WSDL defines a service with a large number of operations.  Each
> > 
> > one
> > 
> > > of them has their own operation-specific schema.
> > > 
> > > When I now marshal the request with CXF, I get a request that is
> > 
> > much,
> > 
> > > much, larger than the original code.  This is because it has xmlns
> > > attributes for EVERY schema referenced in the WSDL, even though only
> > 
> > one
> > 
> > > is referenced in the operation.  What's worse is that that huge list
> > 
> > of
> > 
> > > xmlns attributes is present in two places in the envelope, both on
> > 
> > the
> > 
> > > body child element and in an element in the header.
> > > 
> > > Is there some way I can get the envelope back closer to what I had
> > > before?
> > 
> > --
> > Daniel Kulp
> > [email protected]
> > http://dankulp.com/blog

-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to