httpbuilder
httpbuilder copied to clipboard
setting xml parser features not possible
Using groovy 2.3.7 I get the following error when parsing an xml file with a DOCTYPE
DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true
Is there a way to set the parser features ?
I am encountering this issue too. Any workarounds?
I'm also getting this with Groovy 2.3.9. This will be a show stopper for anyone trying to use http builder in Gradle 2.x plugins.
I figured out a a workaround for this issue. I had to replace the default XML parser with one that can handle the doctype
in an XML file. The following code should do the trick:
restClient.parser.'application/xml' = { response ->
def slurper = new XmlSlurper(false, false)
slurper.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
return slurper.parse(response.entity.content)
}
In my case, restParser
is an instance of RESTClient
, but I think that instances of HTTPBuilder
would work the same way.