users@jaxb.java.net

Re: Envelope has xmlns attributes for EVERY schema defined in WSDL, even if not referenced

From: oliver newell <onewell43_at_gmail.com>
Date: Thu, 11 Nov 2010 19:58:38 -0500

Sounds like its not a good fit. Just for the record the code in the
attachment in conjunction with the setup snippet does work, allowing you to
remove namespaces. The capability was added to JAXB to support building of
XML fragments that are then composed into a larger XML document that is
known to already have the necessary namespaces defined at a higher level.
Works just fine (though if you want to use it dynamically you have to create
the necessary mappers on the fly and CXF probably makes that unwieldy)

On Thu, Nov 11, 2010 at 6:39 PM, KARR, DAVID (ATTSI) <dk068x_at_att.com> wrote:

> I asked about this on the CXF list, and someone pointed out that the
> NamespacePrefixMapper can be used to ADD other namespaces, not remove unused
> ones. In any case, even if it could, it looks like you’re saying to
> hardcode in the invocation code the actual namespaces that are going to be
> used. That would be impractical.
>
>
>
> *From:* oliver newell [mailto:onewell43_at_gmail.com]
> *Sent:* Thursday, November 11, 2010 3:23 PM
> *To:* users_at_jaxb.dev.java.net
> *Subject:* Re: Envelope has xmlns attributes for EVERY schema defined in
> WSDL, even if not referenced
>
>
>
> There is a way in JAXB to supress unwanted namespaces - use a namespace
> mapper when you initialize a marshaller. Comments in the attached example
> mapper should be clear (hopefully) enough to let you configure things the
> way you want. (Use getContextualNamespaceDecls() )
>
> Here's the snippet to setup the mapper. Don't know how to do this in CXF -
> hopefully it is easy to pass the mapper through to the marshaller call
> somehow.
>
> _jc = JAXBContext.newInstance( "net.opengis.wfs.v2" + ":"
> + "net.opengis.fes.v2" + ":" + "net.opengis.gml.v3" + ":"
> + "net.opengis.ows.v1" + ":" + "org.oasis_open.docs.wsn.b_2" +
> ":"
> + "org.oasis_open.docs.wsn.t_1" + ":"
> + "org.oasis_open.docs.wsrf.bf_2" + ":"
> + "org.oasis_open.docs.wsrf.r_2" + ":"
> + "org.w3._2005._08.addressing" );
>
> //
> // Create NamespaceMapper object to tune the appearance/placement of
> // namespace
> // declarations in in the output
> //
> WFSNamespaceMapper wfsNamespaceMapper = new WFSNamespaceMapper();
>
> _marshallerPool = new MarshallerPool( _jc, initialPoolSize,
> wfsNamespaceMapper );
>
> On Tue, Nov 9, 2010 at 1:41 PM, KARR, DAVID (ATTSI) <dk068x_at_att.com>
> wrote:
>
> I'm experimenting with using Apache CXF to consume some web services.
>
> 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?
>
> I asked about this on the CXF list, but they replied that this isn't
> something that CXF can control, it's entirely in the JAXB arena.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>