users@jaxb.java.net

Re: Setting marshaller properties with JAX-WS

From: Adam Zell <zellster_at_gmail.com>
Date: Wed, 4 Aug 2010 01:01:12 -0700

Hello,

On Wed, Aug 4, 2010 at 12:35 AM, Glen Mazza <glen.mazza_at_gmail.com> wrote:

> May I ask, why do you need to control prefixes when you send a SOAP
> message? The web service you call should be able to properly map an
> autogenerated prefix to the namespace declared for it.
>
> The larger issue is that JAXB declares unnecessary namespaces. These can
be removed by overriding NamespacePrefixMapper.getContextualNamespaceDecls.
It should be possible to wrap Bridge<T> and intercept marshal calls with a
Marshaller object. It just seems like there should be an easier way in
JAX-WS.


> Glen
>
> Adam Zell wrote:
>
>> Hello,
>>
>>
>> On Tue, Aug 3, 2010 at 3:21 PM, Adam Zell <zellster_at_gmail.com <mailto:
>> zellster_at_gmail.com>> wrote:
>>
>> Hello,
>>
>> On Tue, Aug 3, 2010 at 2:21 PM, Glen Mazza <glen.mazza_at_gmail.com
>> <mailto:glen.mazza_at_gmail.com>> wrote:
>>
>> This is how it can be done in CXF at least:
>>
>> http://cxf.apache.org/docs/jaxb.html#JAXB-NamespacePrefixManagement
>>
>> Metro is weaker here apparently:
>> http://forums.java.net/jive/message.jspa?messageID=348514
>> (scroll to Andreas' response at the very end of this thread.)
>>
>> I tried the suggestion in the above thread, but for whatever
>> reason the JAXBRIContext object is not being called for a
>> marshaller. Next step is probably going through the JAX-WS source
>> code.
>>
>>
>> Just for completeness, I believe the reason that wrapping the
>> JAXBRIContext does not work is the coupling between JAXBContextImpl and
>> Bridge. JAXBContextImpl defines the following, which is used for
>> marshalling by Bridge:
>>
>> /**
>> * Pool of {_at_link Marshaller}s.
>> */
>> public final Pool<Marshaller> marshallerPool = new
>> Pool.Impl<Marshaller>() {
>> protected @NotNull Marshaller create() {
>> return createMarshaller();
>> }
>> };
>>
>> When Bridge needs a marshaller, it directly accesses the pool instead of
>> calling createMarshaller.
>>
>>
>> Glen
>>
>>
>> Adam Zell wrote:
>>
>> Hello,
>>
>> I would like to control namespaces using a
>> NamespacePrefixMapper and the
>> "com.sun.xml.bind.namespacePrefixMapper" property on a
>> Marshaller. This is fairly straight-forward using JAXB.
>> However, I can't quite see how to do this with JAX-WS.
>> I created a custom JAXBRIContext called via
>> @UsesJAXBContext which wrapped the
>> JAXBRIContext.newInstance() return value, but it doesn't
>> appear that the createMarshaller() method is ever called.
>>
>> Is there a better way to do this?
>>
>> -- Adam
>> zellster_at_gmail.com <mailto:zellster_at_gmail.com>
>> <mailto:zellster_at_gmail.com <mailto:zellster_at_gmail.com>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> <mailto:users-unsubscribe_at_jaxb.dev.java.net>
>>
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>> <mailto:users-help_at_jaxb.dev.java.net>
>>
>>
>>
>>
>> -- Adam
>> zellster_at_gmail.com <mailto:zellster_at_gmail.com>
>>
>>
>>
>>
>> --
>> Adam
>>
>> zellster_at_gmail.com <mailto:zellster_at_gmail.com>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Adam
zellster_at_gmail.com