on 01-05-2015 11:52 AM
Hi Experts ,
My scenario is proxy to JDBC,Where request is going to target system and we are getting response successful but some special character are comming in the response .
Below is the error in monitor .
MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
<SAP:P1>com/sap/xi/tf/_mm_get_lista_res_to_res_</SAP:P1>
<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException:</SAP:P2>
<SAP:P3>Character reference "�" is an invalid XML ch</SAP:P3>
<SAP:P4>aracter.</SAP:P4>
<SAP:AdditionalText />
<SAP:Stack>Runtime exception occurred during application mapping com/sap/xi/tf/_mm_get_lista_res_to_res_; com.sap.aii.utilxi.misc.api.BaseRuntimeException:Character reference "&#xd83d" is
After analyzing the response we found response is comming wih some special character like below
<MESSAGEFORGUEST>Para ajudar aos amigos e familiares segue a lista dos nossos sonhos para nossa casa </MESSAGEFORGUEST>
I am attached the screen shot also for error reference.
How to handle the above special character in PI or is there any option to handle in ECC system.
Please help us to solve the issue.
Regards
Ravi.
Ravi,
Sender system should send well-formed XML. w3c Link. It is highly recommended to fix this in sender system. I agree with and . If it can't be fixed in sender system, please implement below solution.
Solution:-
1) In OM select below Java mapping before MM.
2) Tweak the logic, if needed. It is difficult write generic logic as & is Predefined Entities of XML.
package com.javaMapping;
import java.io.*;
import com.sap.aii.mapping.api.*;
public class Wellformed_JavaMapping extends AbstractTransformation {
@Override
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try {
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
// a) Copy Input content to String
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String inputContent = new String(b);
// b) Replace & with & Use this when every & in input is not escaped as &
inputContent = inputContent.replaceAll("&", "&");
// Use this when a few & are escaped as & and a few & are not escaped. This logic will avoid & to become &amp;
//inputContent = inputContent.replaceAll("&", "____someTEXT_____").replaceAll("&", "&").replaceAll("____someTEXT_____", "&");
outputstream.write(inputContent.getBytes());
} catch (Exception exception) {
getTrace().addDebugMessage(exception.getMessage());
throw new StreamTransformationException(exception.toString());
}all
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
Thanks for your replay.
i have one query for above java mapping .In my scenario response having & in multiple places
where some filed level & is automatically converting like &: in the xml,
where the special character are comming there its not converting.
if i use above code it my be consume duplicates & in the response ?
Below is my scenario :
same response its converting & As a &
<DESCRIPTION>Casamento Bruna Monteiro e Fabrício Santos</DESCRIPTION>
<MESSAGEFORGUEST>Muito obrigada por fazer parte deste momento único em nossas vidas.
Bruna & Fabrício</MESSAGEFORGUEST>
in the same response Its not converting for special chracters
<MESSAGEFORGUEST>Para ajudar aos amigos e familiares segue a lista dos nossos sonhos para nossa casa������������������</MESSAGEFORGUEST>
<NAME></NAME>
If i use the above code it will replace & with &amp?
Regards
Ravi
Ravi,
This is not a problem with language characters. It seems Unicode (UTF-8) representation of Emoticons are not properly escaped in XML.
1) Please download the payload from MONI and save it as .txt file.
2) Open the payload with notepad++ or foxe editor.
3) Paste the screenshot here in the SCN, where MESSAGEFORGUEST is present. We would be able to help.
FYI. In XML &, <, >, ; ,' should not be present in XML data, without escape sequence. Link.
Emoji Link.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu ,
Hope you doing great!.
Thanks for the replay .Please find the below xml message which i copy from the moni from PI and pasted in notepad++ .
which is converting some special character in notepad ++ and text pad.
<DESCRIPTION>casamento de Lorena e Marcelo</DESCRIPTION>
<MESSAGEFORGUEST>Para ajudar aos amigos e familiares segue a lista dos nossos sonhos para nossa casa������������������</MESSAGEFORGUEST>
<NAME></NAME>
We already implemented the note 1415467 - Reject illegal characters for some other special character . in the above xml smile should not converting in the special character in PI level .how to handle this.
If it convert into some special characters we can handle.
Please give your valuable inputs for this to handle the special character .
Regards
Ravi
Hello Ravi,
It is best if the sender system can avoid sending such characters to PI. if this can't be done you will need to handle it in PI java/XSLT mapping.
You can refer to the below link which talks about handling such characters https://discussion.evernote.com/topic/27354-emoji-is-regarded-as-invalid-xml-character/
You can write Java code to achieve the above.
BR<
Diptee
Hi Ravinder,
I can notice that your sender system is an ABAP one, you can try to set the connection to unicode like this note explains: 1768901 - PI mapping runtime ParserException
The java mapping solution can be use to determine what character to accept, easier than to set the erroneous (like this other Dubey Sachi's example ). The Portuguese characters should be accepted in the mapping, i think the problem is with a special control one.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Harish,
Thanks for the replay.
I tested the response using view source the above error is due to the special character only.
If go for java mapping need to maintain the all the special character in the code level right?
if we maintain some range only these special character some Brasil language we can not avoid the using java mapping Is there any note for the above issue.
Regards
Ravi.
Hi Ravi,
did you try to test the response message mapping with payload (by view source)? Please check if it is because of special char or any other operation/function in message mapping.
regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
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.