on 02-25-2015 3:05 PM
Hi,
I have a File -> PI -> ECC scenario.
Every now and then i get an error in the mapping and the error is this:
<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException:</SAP:P2>
<SAP:P3>An invalid XML character (Unicode: 0x1a) was found</SAP:P3>
<SAP:P4>in the element content of the document.</SAP:P4>
The error is caused because the file i receive contains names with a unicode character.
I can only make it visible in Notepad. The little arrow in the name is what causes the error.
If i remove the little arrow from the name, the processing works fine.
So that is my description of the error.
I've been looking on scn and found some descriptions of the issue, but never a real solution.
Now it would be best of course not to send the unicode character in the first place but that is not feasible at the moment, so I am looking for ways to remove the character before the XML is created.
Are there ways to do this?
My thoughts go to "Run Operating System Command Before Message Processing"
Is that an option to remove the character? If so, what steps should i follow to achieve this?
Are there other options?
Regards
Robert
Hi Robert!
You could try to use following java code to replace that character:
private String stripNonValidXMLCharacters(String in) {
if (in == null || ("".equals(in))) return null;
StringBuffer out = new StringBuffer(in);
for (int i = 0; i < out.length(); i++) {
if(out.charAt(i) == 0x1a) {
out.setCharAt(i, '-');
}
}
return out.toString();
}
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First i tried to set the file encoding to UTF-16
But that did not solve my error.
Then i tried the advice on the module. I inserted the MessageTransformBean as follows:
Is that done correctly? If it is correct then it doesn't help either. If it is not correct, then please advice on how to do it proper.
Regards
Robert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert
Two things:
i) Sequence of MTB is incorrect. It should be before CallSapAdapter
ii) Module name is incorrect. It should be AF_Modules/MessageTransformBean as that is the JNDI name in the server. Refer SAP library below.
You can also always check what is the correct name to use for a module by checking in the JNDI Browser of NWA - example shown in Step 1 of the following article.
Rgds
Eng Swee
Hi Eng Swee,
Thx for pointing out the correct way to implement the MessageTransformBean.
Unfortunately it didn't help me in getting rid of the message mapping error for that Unicode character.
So i guess i'll try the Java Mapping now.
First time to do that for me, but i guess i can do as was described in the link.
Regards
Robert
Hi Robert,
have you tried to change file encoding?
I had a similar problem and I solved it setting file encoding as UTF-16, that manage UNICODE characters.
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robert,
On second thought. After seeing "Fabio" response, I am updating my response.
It might be an encoding issue. Please try MessageTransformationBean: Transfer.ContentType = text/xml;charset="cp1252" OR utf-8.
OR
Best solution is to request source system to send a well-formed XML (the XML which is failing in message mapping is not well-formed). If it is not possible to change the source program, please follow below solution.
In Java mapping .replaceAll("&", "&") OR .replaceAll("", "") //removing that substitute. FYI. Unicode character table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.