cancel
Showing results for 
Search instead for 
Did you mean: 

How to resolve Content not allowed in prolog with PDF files

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

How should the target of the mapping look like?

Just the file path, and the PDF is dropped?

Former Member
0 Kudos

The mapping is only the file path/file name.

The file content is not mapped to anything and is placed into a designated archive folder configured in the communication channel.

The archiving works fine. The error I get specifically complains about the mapping itself. Hope that helps

stefan_grube
Active Contributor
0 Kudos

The best way to solve this is an adapter module.

There you can influence the ASMA field without changing the message payload.

Java mapping would be possible also.

Former Member
0 Kudos

Is using a custom adapter module the standard way to handle files when we do not want the content? If so does anyone have generic code that we can use for the purposes of simply monitoring a file and passing the file name/folder out implemented as modules already?

Is this a known workaround to get around the "content not allowed in prolog" issue?

stefan_grube
Active Contributor
0 Kudos

> Is using a custom adapter module the standard way to handle files when we do not want the content?

I would rather say this is a feasible solution

> If so does anyone have generic code that we can use for the purposes of simply monitoring a file and passing the file name/folder out implemented as modules already?

The questio is. What do you want to do with this information?

Here is a sample code written for a specific purpose, you can adapt this to your needs:

http://wiki.sdn.sap.com/wiki/display/XI/AdapterModulePI7.0SetAttachmentName

> Is this a known workaround to get around the "content not allowed in prolog" issue?

At least it is known by me

Former Member
0 Kudos

So, finally back to this again...I have a shell for a module based on the code sample you referred me to. My next questions is specifically around what do I do with it ?

First, I want to ignore the file content and not even read it if I can. All I need is the file name, and path information and return that as the adapter payload. Is that even possible? Seems like I am bypassing the core file adapter module.

Second, when I manage to get an EAR file built to deploy, what do I put in the channels module configuration? I am assuming I would replace the default file one since I don't want the file content?

I am new to building modules so please forgive me naivety.

stefan_grube
Active Contributor
0 Kudos

Do I understand this correct: You want to drop the whole file?

What about following: you write an OS script which looks for fiels in a folder, reads the file name and creates a small text file with just the information you want?

The text file can be processed by file adapter. You need no Java, no adpter module, no mapping.

HHA
Discoverer
0 Kudos

Hi,

we have the same problem.

did you resolved it?