Stream: hapi
Topic: hapi-fhir: issue 266: Parsing of XML fails if response co...
Zulip HAPI Bot (Dec 03 2015 at 14:19):
psosm opened issue 266
I have just tried to get the conformance profile from the spark server at furore.com
using:client.fetchConformance().ofType(Conformance.class).execute();
the execution failed leaving a stack trace like:
ca.uhn.fhir.parser.DataFormatException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content ist nicht zulässig in Prolog.
at ca.uhn.fhir.parser.XmlParser.doXmlLoop(XmlParser.java:253)
at ca.uhn.fhir.parser.XmlParser.parseResource(XmlParser.java:1036)
at ca.uhn.fhir.parser.XmlParser.doParseResource(XmlParser.java:191)
at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:474)
at ca.uhn.fhir.rest.client.BaseClient$ResourceResponseHandler.invokeClient(BaseClient.java:531)
at ca.uhn.fhir.rest.client.BaseClient$ResourceResponseHandler.invokeClient(BaseClient.java:504)
at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:354)
at ca.uhn.fhir.rest.client.GenericClient$BaseClientExecutable.invoke(GenericClient.java:648)
at ca.uhn.fhir.rest.client.GenericClient$FetchConformanceInternal.execute(GenericClient.java:931)
at ca.uhn.fhir.rest.client.RestfulClientFactory.validateServerBase(RestfulClientFactory.java:293)
at ca.uhn.fhir.rest.client.RestfulClientFactory.validateServerBaseIfConfiguredToDoSo(RestfulClientFactory.java:209)
at ca.uhn.fhir.rest.client.BaseClient.invokeClient(BaseClient.java:188)
at ca.uhn.fhir.rest.client.GenericClient$BaseClientExecutable.invoke(GenericClient.java:648)
at ca.uhn.fhir.rest.client.GenericClient$FetchConformanceInternal.execute(GenericClient.java:931)
Zulip HAPI Bot (Dec 03 2015 at 14:22):
As far as i can see there ist a problem if the response body is preluded with a byte order mark (BOM)
Changing BaseClient.java to use a BOMInputStream (of commons-io) as source for the reader in createReaderFromResponse fixed the problemI have changed line 494 of BaseClient.java from
Reader reader = new InputStreamReader(theResponse.getEntity().getContent(), charset);
to
BOMInputStream bomInputStream = new BOMInputStream(theResponse.getEntity().getContent(), false);
Reader reader = new InputStreamReader(bomInputStream, charset);
which solved the problem
Last updated: Apr 12 2022 at 19:14 UTC