cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong Characters returned by the WebService

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I solved it converting the code-page from the return of the web-service:


* 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.