Skip to Content
avatar image
Former Member

How to resolve Content not allowed in prolog with PDF files

We are using PI 7.1 to read a file and using ASMA get the file name and pass it to a target mapping and call a web service with the file name.

We have a scenario that reads a PDF file as Binary form a folder. Our mapper uses ASMA to get the file name and folder of the

file to map to the target.

Testing in mapper works fine except for the ASMA does not function (known issue).

At runtime we drop a file and it is picked up as expected BUT from SXMB_MONI we see the following:

Runtime exception occurred during application mapping com/sap/xi/tf/_MM_FileNotification_; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Content is not allowed in prolog.

This error does not happen all the time either. When it appears it is typically only the first time a file is mapped and on subsequent retries it processes normally. In dev we have shown that PI seems to get stuck on a few initial files u2013 process properly on the first retry and then at some point has no issues and will process files very fast.

u201CContent not allowed in prologu201D at least from an XML perspective is related to characters appearing before the xml file declaration:

<?xml version="1.0".encoding="UTF-8"?>

If chars appear before this you get this error in Java parsers. This could be related but we do not have control over how PI parsed the file content and puts into XML messages inside the mapper as we do nothing with the file content.

The same file will go through randomly with this exception on multiple drops. Sometimes it gets processed properly and sometime it doesnu2019t u2013 but in dev it u201Calwaysu201D gets processed properly on the automatic retry. It does not seem to matter what PDF we drop in there either.

Our tyoes look something like this:

Source:

DT_FILE - xsd:hexBinary

Target:

FilePath - xsd:String

I have tried with DT_FILE as xsd:base64Binary with the same results...

We use a UDF to get the file name from ASMA as follows:

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");

String ourSourceFileName = conf.get(key1);

String ourSourceDirName = conf.get(key2);

//conf.put(key1, ourSourceDirName + "/" + ourSourceFileName);

return ourSourceDirName + "
ToProcess
" + ourSourceFileName;

Edited by: Carey Bingham on May 26, 2010 12:24 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 26, 2010 at 11:16 AM

    How should the target of the mapping look like?

    Just the file path, and the PDF is dropped?

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 15, 2011 at 01:49 PM

    ideally for this i would prefer a java mapping based solution;

    you can have the file read as binary and then pass the inputstream to the outputstream ensuring that the PDF content flows thru fine and then put in the snippet for dynamic configuration in the mapping.

    Message mapping technique you have used is prone to issues

    Add comment
    10|10000 characters needed characters exceeded