Encounter The XML could not be parsed. Content is not allowed in prolog while calling external web service

0
When calling an external soap based webservice (which I cannot adjust) I encounter the error message: The XML could not be parsed. Content is not allowed in prolog   com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: The XML could not be parsed. Content is not allowed in prolog.     at Integration.ReportContent_GetAttachment (Import with mapping : 'Import from XML') Advanced stacktrace:     at com.mendix.basis.component.InternalCoreBase.execute(InternalCoreBase.java:389) Caused by: com.mendix.modules.microflowengine.MicroflowException: The XML could not be parsed. Content is not allowed in prolog.     at Integration.ReportContent_GetAttachment (Import with mapping : 'Import from XML') Advanced stacktrace:     at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:146) Caused by: com.mendix.integration.importer.ImportParseException: The XML could not be parsed. Content is not allowed in prolog. ... Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)     at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)     at com.mendix.integration.importer.xml.XmlImporter.$anonfun$parseXml$1(XmlImporter.scala:71)     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)     at scala.util.Try$.apply(Try.scala:209)   I have set webservice logging to trace and found that the webservice in fact does return a response containing all expected data. I found several possible causes for the error on this forum and in other sources, however since I can’t change the webservice I am calling, I think I am stuck. I did find a workaround using an error handler on the webservice action, when an error is encountered I use the $latestHttpResponse variable which contains the WS response, remove any additional info in the message and then use Import with mapping action to map the ‘cleaned’ WSResponse to the original import mapping. It then works fine.  Still wondering whether there is any other possible solution (since using the error handler as a standard process step seems weird). Any recommendations?   
asked
1 answers
1

Brian

In the Rest call activity, instead of using an import mapping for the response, you can choose the option to store the response in a string variable.  Then you can clean up the response and proceed to an import mapping.

Mike

answered