Hi! Consider this web service implemented in Java:
@WebMethod(operationName = "test1") @WebResult(name = "test1", targetNamespace = "http://test.example.org/") public String test1() { return "foo\u0000bar"; // "foo" + NUL + "bar" } Using (versions 2.5.10 and 2.7.18 of) apache CXF, this will return to the client (SOAP envelope omitted): <ns2:test1>foo[NULL byte here]bar</ns2:test1> Which is invalid XML. What is the correct standard handling of cases like this? Note: I did not test CXF 3.x as I requires changes to my dev environment( newer version of various libraries). I googled and found ... not much. This is a related issue from Axis: https://issues.apache.org/jira/browse/AXIS-2025 "Illegal XML characters in String arguments and return values cause XML exceptions in Axis calls" Note2: I posted this question here first: https://stackoverflow.com/questions/53280783/how-to-handle-string-data-characters-that-are-illegal-in-xml Regards, David