2011/10/27 David Karlsen <[email protected]>:
> Didn't my suggestion for workaround work (configure a woodstox
> instance and injecting it in the jax-ws endpoint) work?

If you want to ignore those invalid characters (i.e., replacing them
with some valid character, thereby losing the information), you can
use the woodstock approach suggested here earlier. In this case, you
can write your own stax output factory something like:

package tmp;

public class MyWstxOutputFatory extends WstxOutputFactory {
    public MyWstxOutputFatory() {
        
setProperty(com.ctc.wstx.api.WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
                    new
com.ctc.wstx.api.InvalidCharHandler.ReplacingHandler(' '));
    }
}

and use it in your jaxws configuration
   <bean id="outStaxFactory" class="tmp.MyWstxOutputFatory"/>

   <!-- jaxws:client or server -->
       ...
       <jaxws:properties>
           <entry key="javax.xml.stream.XMLOutputFactory">
               <ref bean="outStaxFactory"/>
           </entry>
       </jaxws:properties>
       ...

But the consequence of this approach is that you cannot recover those
invalid characters from the serialized content. If you need to
transfer the information without loss, I think you will need to use
other approaches.

- use base64 by using binary type
- use your own proprietary encoding rule for those characters (you
cannot use the standard character encoding in xml 1.0)
(this is only possible if there is a valid xml character that is not
in your dataset's domain).

regards, aki



>
> 2011/10/26 Daniel Kulp <[email protected]>:
>> On Wednesday, October 26, 2011 2:02:54 PM Conficio wrote:
>>> Thanks Dan,
>>> for your comment. I agree if feed invalid XML it should complain.
>>>
>>> However in my situation, I'd think that if I use some Java bean with a
>>> String attribute and CXF on the server and client side, the the marshaling
>>> and un-marshaling does take care of escaping characters that are not allowed
>>> in XML.
>>
>> The point is that there are certain characters that CANNOT be represented in
>> XML at all, escaped or not.   CXF DOES escape the characters that are valid.
>> (well, woodstox does)   However, if the character cannot be stuck in XML,
>> escaped or otherwise, it needs to throw an exception.
>>
>>
>>> What surprises me here is that only the client does complain with the
>>> exception, but the server happily puts out the invalid XML.
>>
>> Possibly a different XML parser.    Woodstox is pretty strict about being
>> compliant.   Other parsers might not be.
>>
>> Dan
>>
>>
>>
>>>
>>> --
>>> View this message in context:
>>> http://cxf.547215.n5.nabble.com/String-with-Ctrl-Character-marshalling-unma
>>> rshalling-error-tp4924570p4941165.html Sent from the cxf-user mailing list
>>> archive at Nabble.com.
>> --
>> Daniel Kulp
>> [email protected]
>> http://dankulp.com/blog
>> Talend - http://www.talend.com
>>
>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen
>

Reply via email to