Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Wrong Characters returned by the WebService

Former Member
0 Likes
1,254

Hi!

I have an scenario where i have one RFC Function module that call a WebService (Java/EJB) that brings the information from a Oracle DB. The RFC parse the results and populate my return tables.

When i call the WebService from wsnavigator in portal(http://url:port/wsnavigator), it returns the words with the special characters OK, eg: "Pend

ê

ncia".
But, when i call the WebService from the RFC Module in ABAP, using the interface if_http_client to make the WebService Call, it returns bogus characters, eg: "Pendência".
So, if my table in Oracle DB have the word "Pendência", the RFC call result will be "Pend

ê

ncia". The same happens with the following characters: áéíóúãàòìùäëïöüãõâêîôûçñ...

This situation only happens when i call the WebService from ABAP using the interface if_http_client, and it looks like the charset is wrong, but when i set the header of the HTTP REQUEST, i set the charset to iso-8859-1, as follows:

-

-


...

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_method'

value = 'POST'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~server_protocol'

value = 'HTTP/1.1'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Type'

value = 'text/xml; charset=iso-8859-1;'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Length'

value = txlen.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'SOAPAction'

value = ''.

...

-

-


Any idea?

Thanks in advance.

2 REPLIES 2
Read only

Former Member
0 Likes
519

May be you don't have the right code page. I am not an expert, but check on that aspect with your basis administrators.

Here is the documentation related to code pages.

SAP character set identification

Definition

The 4-character name of an SAP character set as defined

in SAP character set maintenance.

The following explains the naming convention in more detail:

First digit: Code

0 EBCDIC character sets

1 ASCII character sets

2 mixed single byte / double byte character sets

4 double-byte character sets

6 mixed character sets

8 double byte and multibyte character sets

9 reserved for code pages you define

Second digit: Country

1-3 countries that use the Latin alphabet (Western Europe, North and South America, Australia, Africa)

4-6 countries that use non-Latin alphabets and writing

systems (Eastern Europe, Asia, Arabic countries in Africa)

7-9 reserved for special languages

Third and fourth digits: Sequential number

Example

0100 IBM 00697/00273 (Latin 1 - Germany/Austria)

0401 SNI BS2000 8859-5 EHCLC (cyrillic - multiple languages)

The table is TCP00.

Message was edited by: Srinivas Adavi

Read only

Former Member
0 Likes
519

I solved it by converting the code-page in the return of the webservice call...


* After receive the return from the WebService,
* move the result to the string wf_string1.
  clear wf_string1 .
  wf_string1 = http_client->response->get_cdata( ).
* Some variables
data: conv type ref to cl_abap_conv_in_ce,
        wf_stringx type xstring,
        viewoff type ref to cl_abap_view_offlen,
        len type i,
        content type string.

* Convert the return string of the webservice to Hexadecimal
  call function 'SCMS_STRING_TO_XSTRING'
    exporting
      text     = wf_string1
      mimetype = ''
    importing
      buffer   = wf_stringx.
* call the method to convert UTF-8(Code-page 4110) to ISO-8859-1(1100)
  conv = cl_abap_conv_in_ce=>create(
                        encoding = '4110'
                          endian = 'L'
                           input = wf_stringx ).

* Read the conversion result
  conv->read(
   exporting
     view = viewoff
   importing
     data = content
     len  = len ).
* Result string...
  wf_string1 = content.