You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by André von Deetzen <vo...@gmail.com> on 2014/10/13 14:30:05 UTC
Adding a String/Element to a response and changing namespaces dynamically
Hi,
1. I'm having a pre-generated xml (snippet) as String and have to insert it
into the output of my Response. Currently I'm not sure how to do this
inside an out-interceptor. What is the best way to do this?
2. I want to transform the namespaces during a response. I've noticed the
TransformationFeature but it's not a static transformation. I'm having a
namespace defined xmlns:foo="http://foo.local/entity" (sample one). My
current challenge is to transform different namespaces for Consumer a and
b. A wants to have xmlns:entity and B wants it to be xmlns:ns1. So again my
question what is the best way to deal with such a requirement? Changing the
consumer implemenation is not possible.
Thanks in advance for your help.
Best regards
André
Re: Adding a String/Element to a response and changing namespaces
dynamically
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 13/10/14 13:30, André von Deetzen wrote:
> Hi,
>
> 1. I'm having a pre-generated xml (snippet) as String and have to insert it
> into the output of my Response. Currently I'm not sure how to do this
> inside an out-interceptor. What is the best way to do this?
>
> 2. I want to transform the namespaces during a response. I've noticed the
> TransformationFeature but it's not a static transformation. I'm having a
> namespace defined xmlns:foo="http://foo.local/entity" (sample one). My
> current challenge is to transform different namespaces for Consumer a and
> b. A wants to have xmlns:entity and B wants it to be xmlns:ns1. So again my
> question what is the best way to deal with such a requirement? Changing the
> consumer implemenation is not possible.
>
CXF ships XSLT in/out interceptors. So you can have a single template
with a parameter telling the template which prefix to use. One XSLT out
interceptor would set to it one value, another interceptor to the other
value. The custom out CXF interceptor (early in the out chain) would
check the consumer id and add the right XSLT out interceptor to the
message chain.
The problem here is that for a thread-safety to be maintained one needs
to have two instantiations of the same template but it should work. May
be even a single XSLT out interceptor would do, though you probably do
not want to parse the template on every response...
Cheers, Sergey
> Thanks in advance for your help.
>
> Best regards
> André
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com