on 11-14-2012 5:02 PM
I am tring to read a flat file using Java Mapping but I get the error "receiver determination error: content not allowed in prolog"
I created a simple Message Type <node1></field></node1> and using it in both inbound and outbound interface.
The Java mapping is between these two interfaces.
The mapping program reads the flat file and populates the entire file into this node.
The mapping works fine in Interface Mapping testing.
I am using AEX (7.3)
What am I missing?
Thanks,
Karthik
No good, no good, friends! Still struck.
Tried both Non-operation specific and updated Java mapping.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you see this (very great) blog post?
It shows that the SWCV should be left empty for non-xml data. In this case on your sender side.
Also, try wrapping your caught Exception as a StreamTransformationException and rethrowing it. That way the mapping will result in an error (as desired) instead of an empty OutputStream. If you ignore the error and produce an empty OutputStream, PI could possible treat that as invalid xml.
But I don't really think it is even reaching your mapping if your error is still in Receiver determination so it may be the wrong thing to focus on.
Hmmmm, I'm fresh out of ideas. I built a File to File scenario with the same sender and receiver interface and the only thing that was an issue for me was the the operation-specific setting in the receiver determination. After I disabled that setting the File to File move worked perfectly without any errors about receiver determination.
Thank you all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
XSD for Message Type Used:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://test.xx/rls/ttd" targetNamespace="http://test.xx/rls/ttd">
<xsd:element name="MT_Trg" type="DT_Trg" />
<xsd:complexType name="DT_Trg">
<xsd:sequence>
<xsd:element name="stringinp" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Java Mapping:
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import java.util.Map;
import java.io.*;
public class stringConversion implements StreamTransformation {
String strXML = new String();
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param) {
this.param = param;
}
public void execute(InputStream in, OutputStream out) {
trace =
(AbstractTrace) param.get(
StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Process Started");
try {
StringBuffer strbuffer = new StringBuffer();
byte[] b = new byte[4096];
for (int n;(n = in.read(b)) != -1;) {
strbuffer.append(new String(b, 0, n));
strbuffer.append("\n");
}
strXML = strbuffer.toString();
} catch (Exception e) {
System.out.println("Exception Occurred");
}
String outputPayload =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<ns0:MT_Trg xmlns:ns0=\"http://test.xx/rls/ttd\"><stringinp>"
+ strXML
+ "</stringinp> </ns0:MT_Trg>";
try {
out.write(outputPayload.getBytes());
trace.addInfo("Process Completed");;
} catch (Exception e) {
trace.addInfo("Process Terminated: Error in writing out payload");;
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik,
I have made some minor changes to the code. Try this code
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import java.util.Map;
import java.io.*;
public class stringConversion implements StreamTransformation {
String strXML = new String();
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param) {
this.param = param;
}
public void execute(InputStream in, OutputStream out) {
trace =
(AbstractTrace) param.get(
StreamTransformationConstants.MAPPING_TRACE);
trace.addInfo("Process Started");
try {
StringBuffer strbuffer = new StringBuffer();
byte[] b = new byte[4096];
for (int n=0;(n = in.read(b)) != -1;) {
strbuffer.append(new String(b, 0, n));
}
strXML = strbuffer.toString();
} catch (Exception e) {
System.out.println("Exception Occurred");
}
String outputPayload =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<ns0:MT_Trg xmlns:ns0=\"http://test.xx/rls/ttd\"><stringinp>"
+ strXML
+ "</stringinp> </ns0:MT_Trg>";
try {
out.write(outputPayload.getBytes("UTF-8"));
trace.addInfo("Process Completed");;
} catch (Exception e) {
trace.addInfo("Process Terminated: Error in writing out payload");;
}
}
}
Hope the error resolves.
Regards
Anupam
Hi Karthik,
I found the solution to your problem. See the two different screenshots below for the default receiver determination in AAE vs. the switched setting. It appears the default setting results in some extra validation for the operation piece against the sender interface and that appears to be where your scenario is failing. See below:
default -
not operation-specific -
Regards,
Ryan Crosby
I believe the java progrom is working good.
I want to understand about the configuration part.
Inbound interface structure will be same as the output of the java mapping but what should be the Outbound interface message strucure.
Any difference step while configuring Integration Configuration?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The expected XML structure from the java mapping should match the outbound message structure from PI. If the input is a flat file that's where the java mapping reads the file stream and places it into the expected XML structure for the outbound interface that will then pass the contents along to the receiver. You said it is failing here at the next step of receiver determination. The one thing that is different with java mapping vs. graphical mapping however is that no XML validation occurs during the mapping so it is possible for it to fail at the next step (required fields, correct message type, etc.).
Hi Karthik,
Could you post the java mapping code, the source XSD/XML and target XSD. This error is common to xml documents. Please check this article
http://www.judahfrangipane.com/blog/2006/12/13/content-is-not-allowed-in-prolog/
Regards
Anupam
I agree with you, it is purely configuration error.
This is the java mapping code and I am doing the same thing explained in this blog
http://wiki.sdn.sap.com/wiki/display/XI/Read+Input+Text+File+as+a+Single+Field.
and yes if I paste the same payload in interface mapping. It works
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was able to find the blog by navigating to it. A simple way to verify the output from the java mapping is valid XML would be to export this code as a runnable .jar and execute the program in the system. I used "test.txt" and "out.xml" as the filenames here but that could be changed easily:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.sap.aii.mapping.api.StreamTransformationException;
public class MainProgram
{
public static void main(String[] args)
{
try {
FileInputStream fis = new FileInputStream(new File("test.txt"));
FileOutputStream fos = new FileOutputStream(new File("out.xml"));
xmlpayload map = new xmlpayload();
map.execute(fis, fos);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (StreamTransformationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
If you see anything funky in the XML output file using something like notepad++ then the mapping is the problem, otherwise it would have to be a configuration issue.
It shows receiver determination error. See any problem in the configuration objects. Plus content not allowed in prolog generally appears if the xml syntax is invalid such as not properly closed brackets or so. This is typical xml parser error. please provide more details on this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karthik,
If you copy/paste the full contents of the file into the interface mapping you don't see this issue? Also, can you paste the code to the java mapping here... it may give some more insight into what may be causing the trouble.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.