Skip to Content

How to Handle Special Characters in PI7.1

Hi Team,

I need to handle some special characters like <,>,& etc.. from WS Adapter to CRM in PI 7.1.

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/9420 [original link is broken]

By using the above blog i had implemented the Java Code as

public void execute(InputStream in, OutputStream out){

try{

int read_data;

while((read_data = in.read()) != -1){

if (read_data == '&'){

out.write("&amp;".getBytes());

}else if (read_data == '>'){

out.write("&gt;".getBytes());

}else if (read_data == '<'){

out.write("&lt;".getBytes());

}else if (read_data == '/'){

out.write("&frasl;".getBytes());

}else if (read_data == '\''){

out.write("&apos;".getBytes());

}

else { out.write(read_data);

}

}

out.flush();

} catch (Exception e){}

}

I had added this class file in Operational Mapping.

It is working if we have only one IF condition for & in while

Any suggestion

Thanks

Sriram

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2010 at 01:08 PM

    Hi Sriram,

    Try this code

    public void execute(InputStream in, OutputStream out) {

    try {

    int read_data;

    while ((read_data = in.read())!=-1)

    {

    if (read_data != '&' || read_data != '>' || read_data != '<')

    out.write(read_data);

    else if(read_data.equals("&"))

    out.write("&".getBytes());

    else if(read_data.equals("<"))

    out.write("<".getBytes());

    else if(read_data.equals(">"))

    out.write(">".getBytes());

    }

    out.flush();

    } catch (Exception e) {

    }

    Regards

    Ramesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 26, 2010 at 07:25 AM

    > I need to handle some special characters like <,>,& etc.. from WS Adapter to CRM in PI 7.1.

    Could you describe the issue that you have?

    When you change < and >, then the result is non-XML.

    Add a comment
    10|10000 characters needed characters exceeded

    • > I mean how should the < and > symbols of the payload to be sent by the sender application.

      It should be &amp;lt; and &amp;gt;

      See this document; it is an official document, so no one can deny the validity:

      http://www.w3.org/TR/2006/REC-xml11-20060816/#syntax

      " The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, ... If they are needed (...), they MUST be escaped using either numeric character references or the strings "&amp;amp;" and "&amp;lt;" respectively. The right angle bracket (>) may be represented using the string "&amp;gt;", "

      Edited by: Stefan Grube on Jul 27, 2010 2:03 PM

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.