You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Christophe Collet <co...@gmail.com> on 2013/08/13 13:35:35 UTC

Escaping right angle bracket.

Hi all, 

I have a project that uses CXF 2.4.1 (we haven't migrate yet to an more
recent version...) and i'm facing a problem with right angle bracket
escaping in a soap response.

When a soap fault response is generate, we put a XML formatted value in a
text node.

Our problem is that only left angle brackets are escaped (&lt;) and not
right ones.
I know that right angle bracket escaping is optional based on the XML spec.
but i was wondering if there was a way to enable it ?

 (The client application need to have "&gt;"... despite our response is
correct...)

Regards 
-- 
Christophe Collet






--
View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Christophe Collet <co...@gmail.com>.
Well, i have found a solution to insert a custom "escaper".

First, i need a filterWriter that escapes like i want. I made one
(/CustomXmlEscapingUTFWriter/) based on /com.ctc.wstx.io.UTFTextWriter/. I
add "<" escape in all cases.

I also created a custom /org.codehaus.stax2.io.EscapingWriterFactory/ that
uses my filterWriter.



I finally created a new interceptor that add a XMLOutpuFactory in the
message properties. This factory is then retrieved in StaxOutInterceptor.



I hope this could help other users.

-- 
Christophe




Aki Yoshida-3 wrote
> yes. something like that.
> 
> I think there was somone trying to output illegal XML characters or
> something like that this way. But I couldn't find his posting anymore.
> 
> Then, you can set the context property over the cxf endpoint
> configuration (over its properties).
> http://cxf.apache.org/docs/jax-ws-configuration.html
> <jaxws:properties>
>   
> <entry key="javax.xml.stream.XMLOutputFactory" ref="..."/>
> regards, aki
> 
> 2013/8/14 Christophe Collet &lt;

> collet.christophe@

> &gt;:
>> The escaping seems to be done in com.ctc.wstx.sw.BufferingXmlWriter
>> There's a way to add a custom "escaper" by adding a EscapingWriterFactory
>> in
>> the config of the XMLWriter.
>>
>> The SimpleNSStreamWiter is created from a XMLOutputFactory. It seems that
>> a
>> custom XMLOutputFactory can be passed in the contextualProperty of the
>> message. (retrieved in StaxOutInterceptor).
>>
>> Thus, i need to create my own XMLOutputFactory in order to add a custom
>> EscapingWriterFactory at the XMLWriter instantiation.
>>
>> That's the "cleanest" way i think. But if there's still a "dirty" way
>> that
>> "hard replace" in the outputstream, i'm ok with it right now.
>>
>> Regards
>>
>>
>>
>> --
>> View this message in context:
>> http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732329.html
>> Sent from the cxf-user mailing list archive at Nabble.com.





--
View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732406.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Aki Yoshida <el...@gmail.com>.
yes. something like that.

I think there was somone trying to output illegal XML characters or
something like that this way. But I couldn't find his posting anymore.

Then, you can set the context property over the cxf endpoint
configuration (over its properties).
http://cxf.apache.org/docs/jax-ws-configuration.html
<jaxws:properties>
  <entry key="javax.xml.stream.XMLOutputFactory" ref="..."/>

regards, aki

2013/8/14 Christophe Collet <co...@gmail.com>:
> The escaping seems to be done in com.ctc.wstx.sw.BufferingXmlWriter
> There's a way to add a custom "escaper" by adding a EscapingWriterFactory in
> the config of the XMLWriter.
>
> The SimpleNSStreamWiter is created from a XMLOutputFactory. It seems that a
> custom XMLOutputFactory can be passed in the contextualProperty of the
> message. (retrieved in StaxOutInterceptor).
>
> Thus, i need to create my own XMLOutputFactory in order to add a custom
> EscapingWriterFactory at the XMLWriter instantiation.
>
> That's the "cleanest" way i think. But if there's still a "dirty" way that
> "hard replace" in the outputstream, i'm ok with it right now.
>
> Regards
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732329.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Christophe Collet <co...@gmail.com>.
The escaping seems to be done in com.ctc.wstx.sw.BufferingXmlWriter
There's a way to add a custom "escaper" by adding a EscapingWriterFactory in
the config of the XMLWriter.

The SimpleNSStreamWiter is created from a XMLOutputFactory. It seems that a
custom XMLOutputFactory can be passed in the contextualProperty of the
message. (retrieved in StaxOutInterceptor).

Thus, i need to create my own XMLOutputFactory in order to add a custom
EscapingWriterFactory at the XMLWriter instantiation.  

That's the "cleanest" way i think. But if there's still a "dirty" way that
"hard replace" in the outputstream, i'm ok with it right now.

Regards



--
View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732329.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Aki Yoshida <el...@gmail.com>.
okay.
if you are writing your own writer, I think you can add this special
escaping there.
there is somewhere some simple example to do a similar thing, i need
to look it up.
regards, aki

2013/8/13 Christophe Collet <co...@gmail.com>:
> We are indeed in the case of normal ">", our client doesn't use CDATA
> section.
>
> Actually, "]]>" is correctly escaped in "]]&g t;" and we want the same
> behavior for others ">".
>
> I was thinking that maybe i could add an interceptor in the outgoing chain
> to manually do the escape...
>
>
> Aki Yoshida-3 wrote
>> The escaping happens in the xml writer layer and I don't think there
>> is an option to change the behavior.
>>
>> But I just wanted to make sure that you want to escape the normal ">"
>> appearance which does not need to be escaped? There is a special case
>> when ">" indeed needs to be escaped (i.e., when it appears as part of
>> string "]]>"  within a CDATA section). I hope you are not having this
>> latter case.
>>
>> 2013/8/13 Christophe Collet &lt;
>
>> collet.christophe@
>
>> &gt;:
>>> Hi all,
>>>
>>> I have a project that uses CXF 2.4.1 (we haven't migrate yet to an more
>>> recent version...) and i'm facing a problem with right angle bracket
>>> escaping in a soap response.
>>>
>>> When a soap fault response is generate, we put a XML formatted value in a
>>> text node.
>>>
>>> Our problem is that only left angle brackets are escaped (&l t;) and not
>>> right ones.
>>> I know that right angle bracket escaping is optional based on the XML
>>> spec.
>>> but i was wondering if there was a way to enable it ?
>>>
>>>  (The client application need to have "&g t;"... despite our response is
>>> correct...)
>>>
>>> Regards
>>> --
>>> Christophe Collet
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732295.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Christophe Collet <co...@gmail.com>.
We are indeed in the case of normal ">", our client doesn't use CDATA
section.

Actually, "]]>" is correctly escaped in "]]&g t;" and we want the same
behavior for others ">".

I was thinking that maybe i could add an interceptor in the outgoing chain
to manually do the escape...


Aki Yoshida-3 wrote
> The escaping happens in the xml writer layer and I don't think there
> is an option to change the behavior.
> 
> But I just wanted to make sure that you want to escape the normal ">"
> appearance which does not need to be escaped? There is a special case
> when ">" indeed needs to be escaped (i.e., when it appears as part of
> string "]]>"  within a CDATA section). I hope you are not having this
> latter case.
> 
> 2013/8/13 Christophe Collet &lt;

> collet.christophe@

> &gt;:
>> Hi all,
>>
>> I have a project that uses CXF 2.4.1 (we haven't migrate yet to an more
>> recent version...) and i'm facing a problem with right angle bracket
>> escaping in a soap response.
>>
>> When a soap fault response is generate, we put a XML formatted value in a
>> text node.
>>
>> Our problem is that only left angle brackets are escaped (&l t;) and not
>> right ones.
>> I know that right angle bracket escaping is optional based on the XML
>> spec.
>> but i was wondering if there was a way to enable it ?
>>
>>  (The client application need to have "&g t;"... despite our response is
>> correct...)
>>
>> Regards
>> --
>> Christophe Collet





--
View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274p5732295.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Escaping right angle bracket.

Posted by Aki Yoshida <el...@gmail.com>.
The escaping happens in the xml writer layer and I don't think there
is an option to change the behavior.

But I just wanted to make sure that you want to escape the normal ">"
appearance which does not need to be escaped? There is a special case
when ">" indeed needs to be escaped (i.e., when it appears as part of
string "]]>"  within a CDATA section). I hope you are not having this
latter case.

2013/8/13 Christophe Collet <co...@gmail.com>:
> Hi all,
>
> I have a project that uses CXF 2.4.1 (we haven't migrate yet to an more
> recent version...) and i'm facing a problem with right angle bracket
> escaping in a soap response.
>
> When a soap fault response is generate, we put a XML formatted value in a
> text node.
>
> Our problem is that only left angle brackets are escaped (&lt;) and not
> right ones.
> I know that right angle bracket escaping is optional based on the XML spec.
> but i was wondering if there was a way to enable it ?
>
>  (The client application need to have "&gt;"... despite our response is
> correct...)
>
> Regards
> --
> Christophe Collet
>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Escaping-right-angle-bracket-tp5732274.html
> Sent from the cxf-user mailing list archive at Nabble.com.