cancel
Showing results for 
Search instead for 
Did you mean: 

scenario is proxy to jdbc while response getting error MAPPING">EXCEPTION_DURING_EXECUTE occured .

Former Member
0 Kudos

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 "&#xd83d" 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 &quot;&amp;#xd83d&quot; 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.

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

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 &amp; Use this when every & in input is not escaped as &amp;

            inputContent = inputContent.replaceAll("&", "&amp;");

            // Use this when a few & are escaped as &amp; and a few & are not escaped. This logic will avoid &amp; to become &amp;amp;

            //inputContent = inputContent.replaceAll("&amp;", "____someTEXT_____").replaceAll("&", "&amp;").replaceAll("____someTEXT_____", "&amp;");

          

            outputstream.write(inputContent.getBytes());

        } catch (Exception exception) {

            getTrace().addDebugMessage(exception.getMessage());

            throw new StreamTransformationException(exception.toString());

        }all

    }

}

Former Member
0 Kudos

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 &amp: in the xml,

where the special character are comming there its not converting.

if i use above code it my be consume duplicates &amp; in the response ?


Below is my scenario :

same response its converting & As a &amp;

<DESCRIPTION>Casamento Bruna Monteiro e Fabrício Santos</DESCRIPTION>

  <MESSAGEFORGUEST>Muito obrigada por fazer parte deste momento único em nossas vidas.

Bruna &amp; 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&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;</MESSAGEFORGUEST>

  <NAME></NAME>

If i use the above code it will replace &amp; with   &amp;amp?


Regards

Ravi

RaghuVamseedhar
Active Contributor
0 Kudos

Ravi,

Every & should be escaped as &amp; if it is present in data. <Name>AT&T</Name> is not well-formed, graphical mapping will not accept this XML. It should be <Name>AT&amp;T</Name>.

Former Member
0 Kudos

Hi Raghu,

Yes Your right my friend .

We will try the same .

Thanks for your support and knowledge sharing .

Regards

Ravi.

RaghuVamseedhar
Active Contributor
0 Kudos

Ravi,

FYI. Here is my blog with details about well-formed XML.

Not well-formed XML - & issue

Answers (4)

Answers (4)

RaghuVamseedhar
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde03;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;&#xd83d;&#xde0d;</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

Former Member
0 Kudos

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

iaki_vila
Active Contributor
0 Kudos

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.

iaki_vila
Active Contributor
0 Kudos

Hi Ravinder,

You will need a previous java mapping to omit the special characters. Check this doc:

Regards.

Former Member
0 Kudos

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.

Harish
Active Contributor
0 Kudos

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