on 06-13-2006 11:17 AM
Dear all,
I am new to XI and got a question concerning XI Mapping Lookup API - I send an RFC Request, which comes back as RFC Response(XML), that I fill in a String to map on.
My problem is, characters such as "Ä,ä,Ü,ß" and so on come back pretty weird and I also got a lot of quotes in my String. Could somebody please give me a hint how to move on with this..
thanx in advance
P.S. Is it usefull to handle this problem using the DOM Parser instead holding the response in a string?
Info: called system is R/3 4.6b, XI runs on 6.4 SR 16
Hi all,
my problem is not longer the escaping of the xml chars, such as "<", ">", "/", I solved that, using classes from Apache with the following code snippet
// ioutils is an class from org.apache.commons.io, that allows you to copy InputStream to StringWriter, setting charset as shown below:
Payload resultOfCall = accessor.call(payload);
InputStream in = resultOfCall.getContent();
ioutils.copy(in,stringWriterTemp,"ISO-8859-1");
content=stringWriterTemp.toString();
- the result String looks now like this:
<rfc:Z_GETFTXC108TXTFROMFILE2.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><SCENOEDITXTSTRUCT><br /><MANDT>030</MANDT><SCENARIOID>TVPN</SCENARIOID><br /><FILENAME>c: est est.txt</FILENAME><br /><FILETYPE>ASC</FILETYPE><br /><TEXT1>1 à | ä</TEXT1> (should be Ä | ä)<br /><TEXT2>2 à | ö</TEXT2> (should be Ö | ö)<br /><TEXT3>3 à | ü</TEXT3> (should be Ü | ü)<br /><TEXT4>4 Ã</TEXT4> (should be ß)<br /><TEXT5>5 AAAAAA</TEXT5><br /></SCENOEDITXTSTRUCT></rfc:Z_GETFTXC108TXTFROMFILE2.Response>
@ Stefan
Because I plan to write the plain texts from 1,2,3,4,5
into global container and provide later, the structure
is fine - but how can I get the 'special characters'
correct? Doesn't look like they have been escaped,right?
Or are the char's above really encrypted characters for latin charset, that can be parsed and remodeled?
Thanx in advance
rainer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now the characters are no longer escaped, that is right.
The point now is, the string contains UTF-8 double byte characters, but it is treated like latin-1. So you see two characters instead of one.
Try changing:
ioutils.copy(in,stringWriterTemp,"ISO-8859-1");
to
ioutils.copy(in,stringWriterTemp,"UTF-8");
Regards
Stefan
Hi all
We have had the same problem yesterday.
It seems that it is only a problem by calling an RFC with mapping lookup.
By using sync Message Interface it work.
We checked the apache packed and found out that it is not necessary to use this.
Define a new String for encoding parameter and use the normal InputStreamReader(in,NEWSTRING).
This works.
Sample:
String vEncodeUTF = "UTF-8";
....
// 5. Execute lookup.
Payload result = accessor.call(payload);
InputStream in = result.getContent();
try {
BufferedReader bufReader = new BufferedReader(new InputStreamReader(in,vEncodeUTF));
Cheers Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The RFC adapter escapes all non-ascii values with the code page value enlosed with the escaping sequence, for example: „
I don't see another way as parsing the strings and deescpaping these values in your Java program.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear all - thanks for your very fast help but I still have problem with the wrong character...
@Michal - Using this coding (the easiest way, I found from the WebLog) to convert the Payload type to String, delivers the result I have shown at the end, so could you give me please some approach how to handle this
Payload resultOfCall = accessor.call(payload);
InputStream in = resultOfCall.getContent();
out = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read > 0; read = in.read(buffer)) {
out.write(buffer, 0, read);
}
content = out.toString();
return content;
Result:
<?xml version="1.0" encoding="UTF-8"?><rfc:Z_GETFTXC108TXTFROMFILE2.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><SCENOEDITXTSTRUCT><MANDT>030</MANDT><SCENARIOID>TVPN</SCENARIOID><FILENAME>/usr/sap/text3.txt</FILENAME><FILETYPE>ASC</FILETYPE><TEXT1>Kleines Regengesicht aaLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü2 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü3 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßß1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü3 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßß8 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÜüÖö9 ÄäBbCcDdEeFfGgÖöIxxSTRINGENDE</TEXT1><TEXT2>2 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü1234567890123456789012345678901234567890123456789012345678903 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßß1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678902 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü7 ÄäBbCcDdEeFfGgHhIiJjKkLlMmNnÖöPpQqRrSsTtÜüVvWwXxYyZzßßÖöÜü8 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÜüÖö9 ÄäBbCcDdEeFfGgÖöIxxSTRINGENDE</TEXT2><TEXT3>3 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßKleines Regengesicht aaLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü3 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßß1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678906 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü7 ÄäBbCcDdEeFfGgHhIiJjKkLlMmNnÖöPpQqRrSsTtÜüVvWwXxYyZzßßÖöÜü8 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÜüÖö9 ÄäBbCcDdEeFfGgÖöIxxSTRINGENDE</TEXT3><TEXT4>7 ÄäBbCcDdEeFfGgHhIiJjKkLlMmNnÖöPpQqRrSsTtÜüVvWwXxYyZzßßÖöÜü7 ÄäBbCcDdEeFfGgHhIiJjKkLlMmNnÖöPpQqRrSsTtÜüVvWwXxYyZzßßÖöÜü2 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890Kleines Regengesicht aaLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÄäÜü1234567890123456789012345678901234567890123456789012345678908 AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzßßÜüÖö9 ÄäBbCcDdEeFfGgÖöIxxSTRINGENDE</TEXT4><TEXT5></TEXT5></SCENOEDITXTSTRUCT></rfc:Z_GETFTXC108TXTFROMFILE2.Response>
Thnaks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
put the whole response (before parsing)
into a string and output it
do you see the ? there ?
if not than you'll know it's DOM issue
if you'll see the ? then you'll need to look into some
other things
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
<i>I send an RFC Request, which comes back as RFC Response(XML), that I fill in a String to map on.</i>
Just parse the RFC response message to extract the response out of the XML payload and use it in your mapping.
You can use either a DOM or a SAX parser, but using a DOM makes it very simple.
Just check this blog on how to do the same,
/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
Regards,
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
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.