Question

I am using Play Framework 1.2.4 and trying to parse a SOAP response.

Response is:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
...
</soap:Body>
</soap:Envelope>

When I try to parse it with play.libs.WS.HttpResponse.getXml() I am getting a fatal error:

[Fatal Error] :-1:-1: Invalid encoding name "UTF8".

It is interesting that encoding is not "UTF8" it is "UTF-8". So why I am getting this exception? Any ideas?

Thanks in advance..

Was it helpful?

Solution

I've faced same problem in my xmlrpc server application because of a non-standard client that sent UTF8.

As I found, it is xerces that raise that exception and my fix to bypass it was using EncodingMap class for registering UTF8 as UTF-8:

EncodingMap.putIANA2JavaMapping( "UTF8", "UTF8" );
EncodingMap.putJava2IANAMapping( "UTF8", "UTF8" );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top