Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
3.5k views
in Programming by
I am getting bloe exception in my code while workin with Axis2 code. Any idea whats the matter?

Caused by: java.io.IOException: Invalid white space character (0x7) in text to output (in xml 1.1, could output as a character entity)
    at com.ctc.wstx.api.InvalidCharHandler$FailingHandler.convertInvalidChar(InvalidCharHandler.java:55)
    at com.ctc.wstx.sw.XmlWriter.handleInvalidChar(XmlWriter.java:623)
    at com.ctc.wstx.sw.BufferingXmlWriter.writeCharacters(BufferingXmlWriter.java:554)
    at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:460)
    ... 91 more

1 Answer

0 like 0 dislike
by The go-to Tester (181 points)

Usually while sending or receiving you will get invalid white space due to charset mismatch. You can create wrapper and try below code to resolve it.

/**
* From xml spec valid chars:<br>
* #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]<br>
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.<br>
* @param text The String to clean
* @param replacement The string to be substituted for each match
* @return The resulting String
*/
public static String CleanInvalidXmlChars(String text, String replacement) {
    String re = "[^\\x09\\x0A\\x0D\\x20-\\xD7FF\\xE000-\\xFFFD\\x10000-x10FFFF]";
    return text.replaceAll(re, replacement);
}

Source: http://stackoverflow.com/questions/9710185/how-to-deal-with-invalid-characters-in-a-ws-output-when-using-cxf

...