0

When calling a Webservice that is supposed to return a String with a special character (a kind of cross), I have the following error:

Caused by: javax.xml.stream.XMLStreamException: An invalid XML character (Unicode: 0x10) was found in the element content of the document.
at com.ibm.xml.xlxp2.api.stax.msg.StAXMessageProvider.throwWrappedXMLStreamException(StAXMessageProvider.java:76)
at com.ibm.xml.xlxp2.api.stax.XMLStreamReaderImpl.produceFatalErrorEvent(XMLStreamReaderImpl.java:2013)
at com.ibm.xml.xlxp2.api.jaxb.JAXBXMLStreamReader.produceFatalErrorEvent(JAXBXMLStreamReader.java:316)
at com.ibm.xml.xlxp2.scan.DocumentScanner.reportFatalError(DocumentScanner.java:4821)
at com.ibm.xml.xlxp2.scan.DocumentScanner.reportFatalError(DocumentScanner.java:1205)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanContent2(DocumentScanner.java:1942)
at com.ibm.xml.xlxp2.scan.DocumentScanner.scanContent(DocumentScanner.java:1862)
at com.ibm.xml.xlxp2.runtime.VMContext.scanContent(VMContext.java:501)
at com.ibm.xml.xlxp2.scan.DocumentScanner.nextEvent(DocumentScanner.java:1276)
at com.ibm.xml.xlxp2.api.stax.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:586)
at com.ibm.xml.xlxp2.api.stax.XMLInputFactoryImpl$XMLStreamReaderProxyImpl.next(XMLInputFactoryImpl.java:183)
at com.ibm.xml.xlxp2.api.wssec.WSSXMLInputFactory$WSSStreamReaderProxy.next(WSSXMLInputFactory.java:55)
at org.apache.axiom.om.impl.builder.StAXBuilder.parserNext(StAXBuilder.java:567)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.nextToken(StAXOMBuilder.java:634)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:175)
at org.apache.axiom.om.impl.llom.OMElementImpl.getNextOMSibling(OMElementImpl.java:341)
at org.apache.axiom.om.impl.traverse.OMChildrenQNameIterator.next(OMChildrenQNameIterator.java:118)
at org.apache.axiom.om.impl.llom.OMElementImpl.getFirstChildWithName(OMElementImpl.java:279)
at org.apache.axiom.soap.impl.llom.soap11.SOAP11FaultImpl.getReason(SOAP11FaultImpl.java:128)
at org.apache.axis2.AxisFault.initializeValues(AxisFault.java:202)
at org.apache.axis2.AxisFault.<init>(AxisFault.java:196)
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:521)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:581)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:130)
... 113 more

How can I fix the problem ?

Thank you.

4

1 に答える 1

1

どうやら、エンコーディングは有効ですが、XMLドキュメントは有効ではありません。

私が見つけた唯一の方法は、この記事で説明されています:

http://blog.mark-mclaren.info/2007/02/invalid-xml-characters-when-valid-utf8_5873.html

public String stripNonValidXMLCharacters(String in) {
    StringBuffer out = new StringBuffer(); // Used to hold the output.
    char current; // Used to reference the current character.

    if (in == null || ("".equals(in))) return ""; // vacancy test.
    for (int i = 0; i < in.length(); i++) {
        current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen.
        if ((current == 0x9) ||
            (current == 0xA) ||
            (current == 0xD) ||
            ((current >= 0x20) && (current <= 0xD7FF)) ||
            ((current >= 0xE000) && (current <= 0xFFFD)) ||
            ((current >= 0x10000) && (current <= 0x10FFFF)))
            out.append(current);
    }
    return out.toString();
}  
于 2013-05-09T17:39:37.373 に答える