You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Arthur van Dorp <ar...@gmx.net> on 2012/04/17 17:00:57 UTC

Enforcing the use of non-default-namespace

Hi all

I am trying to switch a webservice client over from Axis2 to CXF 2.5.2 with JAXB for databinding.

The server it is talking to is implemented with Axis2. Whenever I use the CXF client, the Axis2 server ignores some parts of the request. It looks exactly like the problem described in the question over at stackoverflow:

http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-needs-namespace-on-the-soap-envelope/

The request the Axis2 client generates has a namespace prefix for every element whereas the CXF/JAXB generated code uses a default namespace and omits the prefix. Nothing wrong with that in my book, but it doesn't seem to work with the Axis2 server.

Using XMLBEANS for databinding works, but has other downsides. I would like to use JAXB.

Any ideas on how to resolve this problem on the CXF client side (even if it might be an Axis2 bug)?

Thanks and regards

Arthur


-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Re: Enforcing the use of non-default-namespace

Posted by Daniel Kulp <dk...@apache.org>.
The other option is if you configure in a property of:

"soap.env.ns.map"

which is a map of prefix -> ns  and then also add the property of:

"disable.outputstream.optimization", "true"

then you can have fairly complete control over the prefixes that are used 
and have them output on the SOAP:Envelope.  


Dan



On Tuesday, April 17, 2012 05:00:57 PM Arthur van Dorp wrote:
> Hi all
> 
> I am trying to switch a webservice client over from Axis2 to CXF 2.5.2
> with JAXB for databinding.
> 
> The server it is talking to is implemented with Axis2. Whenever I use the
> CXF client, the Axis2 server ignores some parts of the request. It looks
> exactly like the problem described in the question over at stackoverflow:
> 
> http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-ne
> eds-namespace-on-the-soap-envelope/
> 
> The request the Axis2 client generates has a namespace prefix for every
> element whereas the CXF/JAXB generated code uses a default namespace and
> omits the prefix. Nothing wrong with that in my book, but it doesn't seem
> to work with the Axis2 server.
> 
> Using XMLBEANS for databinding works, but has other downsides. I would
> like to use JAXB.
> 
> Any ideas on how to resolve this problem on the CXF client side (even if
> it might be an Axis2 bug)?
> 
> Thanks and regards
> 
> Arthur
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Re: Enforcing the use of non-default-namespace

Posted by Arthur van Dorp <ar...@gmx.net>.
Hi Sergey, Aki

Thanks so much. It works like a charm. For those new to CXF (like me):
http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-JAXWS
describes how to use the transformation feature with JAXWS and without Spring.

Kind regards

Arthur

-------- Original-Nachricht --------
> Datum: Tue, 17 Apr 2012 22:38:24 +0200
> Von: Aki Yoshida <el...@googlemail.com>
> Hi Sergey, Arthur,
> 
> The recent patch  (CXF-4176) in OutTransformWriter preserves the
> namespace prefixes except for the empty prefix (i.e., the default
> namespace) when it is explicitly replaced by the defaultNamespace
> property of OuttransformWriter. So, in order to assign a new prefix to
> those existing default namespaces, you need to explicitly set the
> defaultNamespace property to some value.
> 
> Unfortunately, I discovered one issue with the previous patch and
> needed to make a small correction today (CXF-4244) for 2.6.1-SNAPSHOT
> and 2.5.4-SNAPSHOT.
> 
> So, to use OutTransformWriter for this default namespace removal trick,
> you need
> 
> prior to 2.5.3, the empty prefix is automatically replaced with a
> non-empty prefix
> for 2.5.3 and 2.6.0, it is only replaced when the defaultNamespace
> property is set (however with the issue CXF-4244).
> from 2.5.4 and 2.6.1, it is only replaced when the defaultNamespace
> property is set
> 
> I am sorry for the inconvenience. I will update the documentation with
> this remark.
> 
> regards, aki
> 
> 2012/4/17 Sergey Beryozkin <sb...@gmail.com>:
> > Hi,
> >
> > I think if you simply pass the request through a CXF transformation
> > feature then a prefix will be added, ex, set an outTransformElements
> > property like this:
> >
> > {http://myns}* : {http://myns}*
> >
> > There could be a much simpler option for the JAX-WS fronthend, but I'm
> > not aware of it
> >
> > I haven't tried but my work. The default namespace can also be
> > enforced with the feature of needed
> > HTH
> > Sergey
> >
> > On Tue, Apr 17, 2012 at 4:00 PM, Arthur van Dorp <ar...@gmx.net>
> wrote:
> >> Hi all
> >>
> >> I am trying to switch a webservice client over from Axis2 to CXF 2.5.2
> with JAXB for databinding.
> >>
> >> The server it is talking to is implemented with Axis2. Whenever I use
> the CXF client, the Axis2 server ignores some parts of the request. It looks
> exactly like the problem described in the question over at stackoverflow:
> >>
> >>
> http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-needs-namespace-on-the-soap-envelope/
> >>
> >> The request the Axis2 client generates has a namespace prefix for every
> element whereas the CXF/JAXB generated code uses a default namespace and
> omits the prefix. Nothing wrong with that in my book, but it doesn't seem to
> work with the Axis2 server.
> >>
> >> Using XMLBEANS for databinding works, but has other downsides. I would
> like to use JAXB.
> >>
> >> Any ideas on how to resolve this problem on the CXF client side (even
> if it might be an Axis2 bug)?
> >>
> >> Thanks and regards
> >>
> >> Arthur
> >>
> >>
> >> --
> >> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> >> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
> >
> >
> >
> > --
> > Sergey Beryozkin
> >
> > http://sberyozkin.blogspot.com
> > Talend - http://www.talend.com

-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Re: Enforcing the use of non-default-namespace

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Aki

On Tue, Apr 17, 2012 at 9:38 PM, Aki Yoshida <el...@googlemail.com> wrote:
> Hi Sergey, Arthur,
>
> The recent patch  (CXF-4176) in OutTransformWriter preserves the
> namespace prefixes except for the empty prefix (i.e., the default
> namespace) when it is explicitly replaced by the defaultNamespace
> property of OuttransformWriter. So, in order to assign a new prefix to
> those existing default namespaces, you need to explicitly set the
> defaultNamespace property to some value.
>
> Unfortunately, I discovered one issue with the previous patch and
> needed to make a small correction today (CXF-4244) for 2.6.1-SNAPSHOT
> and 2.5.4-SNAPSHOT.
>
> So, to use OutTransformWriter for this default namespace removal trick, you need
>
> prior to 2.5.3, the empty prefix is automatically replaced with a
> non-empty prefix
> for 2.5.3 and 2.6.0, it is only replaced when the defaultNamespace
> property is set (however with the issue CXF-4244).
> from 2.5.4 and 2.6.1, it is only replaced when the defaultNamespace
> property is set
>
> I am sorry for the inconvenience. I will update the documentation with
> this remark.
>
Thanks a million for spending the time and fixing these issues, the
feature is becoming better and better :-)
I hope I can contribute soon by prototyping an initial code for
shortening the expressions via the introduction of namespace maps, so
that we can start thinking more about the support for basic xpath
expressions

Cheers, Sergey

> regards, aki
>
> 2012/4/17 Sergey Beryozkin <sb...@gmail.com>:
>> Hi,
>>
>> I think if you simply pass the request through a CXF transformation
>> feature then a prefix will be added, ex, set an outTransformElements
>> property like this:
>>
>> {http://myns}* : {http://myns}*
>>
>> There could be a much simpler option for the JAX-WS fronthend, but I'm
>> not aware of it
>>
>> I haven't tried but my work. The default namespace can also be
>> enforced with the feature of needed
>> HTH
>> Sergey
>>
>> On Tue, Apr 17, 2012 at 4:00 PM, Arthur van Dorp <ar...@gmx.net> wrote:
>>> Hi all
>>>
>>> I am trying to switch a webservice client over from Axis2 to CXF 2.5.2 with JAXB for databinding.
>>>
>>> The server it is talking to is implemented with Axis2. Whenever I use the CXF client, the Axis2 server ignores some parts of the request. It looks exactly like the problem described in the question over at stackoverflow:
>>>
>>> http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-needs-namespace-on-the-soap-envelope/
>>>
>>> The request the Axis2 client generates has a namespace prefix for every element whereas the CXF/JAXB generated code uses a default namespace and omits the prefix. Nothing wrong with that in my book, but it doesn't seem to work with the Axis2 server.
>>>
>>> Using XMLBEANS for databinding works, but has other downsides. I would like to use JAXB.
>>>
>>> Any ideas on how to resolve this problem on the CXF client side (even if it might be an Axis2 bug)?
>>>
>>> Thanks and regards
>>>
>>> Arthur
>>>
>>>
>>> --
>>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> http://sberyozkin.blogspot.com
>> Talend - http://www.talend.com

Re: Enforcing the use of non-default-namespace

Posted by Aki Yoshida <el...@googlemail.com>.
Hi Sergey, Arthur,

The recent patch  (CXF-4176) in OutTransformWriter preserves the
namespace prefixes except for the empty prefix (i.e., the default
namespace) when it is explicitly replaced by the defaultNamespace
property of OuttransformWriter. So, in order to assign a new prefix to
those existing default namespaces, you need to explicitly set the
defaultNamespace property to some value.

Unfortunately, I discovered one issue with the previous patch and
needed to make a small correction today (CXF-4244) for 2.6.1-SNAPSHOT
and 2.5.4-SNAPSHOT.

So, to use OutTransformWriter for this default namespace removal trick, you need

prior to 2.5.3, the empty prefix is automatically replaced with a
non-empty prefix
for 2.5.3 and 2.6.0, it is only replaced when the defaultNamespace
property is set (however with the issue CXF-4244).
from 2.5.4 and 2.6.1, it is only replaced when the defaultNamespace
property is set

I am sorry for the inconvenience. I will update the documentation with
this remark.

regards, aki

2012/4/17 Sergey Beryozkin <sb...@gmail.com>:
> Hi,
>
> I think if you simply pass the request through a CXF transformation
> feature then a prefix will be added, ex, set an outTransformElements
> property like this:
>
> {http://myns}* : {http://myns}*
>
> There could be a much simpler option for the JAX-WS fronthend, but I'm
> not aware of it
>
> I haven't tried but my work. The default namespace can also be
> enforced with the feature of needed
> HTH
> Sergey
>
> On Tue, Apr 17, 2012 at 4:00 PM, Arthur van Dorp <ar...@gmx.net> wrote:
>> Hi all
>>
>> I am trying to switch a webservice client over from Axis2 to CXF 2.5.2 with JAXB for databinding.
>>
>> The server it is talking to is implemented with Axis2. Whenever I use the CXF client, the Axis2 server ignores some parts of the request. It looks exactly like the problem described in the question over at stackoverflow:
>>
>> http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-needs-namespace-on-the-soap-envelope/
>>
>> The request the Axis2 client generates has a namespace prefix for every element whereas the CXF/JAXB generated code uses a default namespace and omits the prefix. Nothing wrong with that in my book, but it doesn't seem to work with the Axis2 server.
>>
>> Using XMLBEANS for databinding works, but has other downsides. I would like to use JAXB.
>>
>> Any ideas on how to resolve this problem on the CXF client side (even if it might be an Axis2 bug)?
>>
>> Thanks and regards
>>
>> Arthur
>>
>>
>> --
>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>
>
>
> --
> Sergey Beryozkin
>
> http://sberyozkin.blogspot.com
> Talend - http://www.talend.com

Re: Enforcing the use of non-default-namespace

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi,

I think if you simply pass the request through a CXF transformation
feature then a prefix will be added, ex, set an outTransformElements
property like this:

{http://myns}* : {http://myns}*

There could be a much simpler option for the JAX-WS fronthend, but I'm
not aware of it

I haven't tried but my work. The default namespace can also be
enforced with the feature of needed
HTH
Sergey

On Tue, Apr 17, 2012 at 4:00 PM, Arthur van Dorp <ar...@gmx.net> wrote:
> Hi all
>
> I am trying to switch a webservice client over from Axis2 to CXF 2.5.2 with JAXB for databinding.
>
> The server it is talking to is implemented with Axis2. Whenever I use the CXF client, the Axis2 server ignores some parts of the request. It looks exactly like the problem described in the question over at stackoverflow:
>
> http://stackoverflow.com/questions/9537462/cxf-codegen-generated-client-needs-namespace-on-the-soap-envelope/
>
> The request the Axis2 client generates has a namespace prefix for every element whereas the CXF/JAXB generated code uses a default namespace and omits the prefix. Nothing wrong with that in my book, but it doesn't seem to work with the Axis2 server.
>
> Using XMLBEANS for databinding works, but has other downsides. I would like to use JAXB.
>
> Any ideas on how to resolve this problem on the CXF client side (even if it might be an Axis2 bug)?
>
> Thanks and regards
>
> Arthur
>
>
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com