Application Development 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: 

Sending French characters as POST request parameter

Amey-Mogare
Contributor
0 Kudos
484

Hi,

I am using HTTP_CLIENT to send/receive data from a JAVA web service from ABAP program.

There will be the case when I need to send French/Norwegian characters as URL's request parameter.

(this Java URL expects a xml as a application parameter)

But at JAVA side, these special language specific characters are getting corrupted.

Is there any way to apply some sort of locale based encoding?

Following is the code I am using:-


MOVE 'http://host:port/a7/SearchRequirements.a7x' TO L_URL.
MOVE 'inputXML=<?xml version="1.0" encoding="iso-8859-1"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Norwegian: æøå. French: êèé</body></note>' TO L_PARAMS_STRING.

CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
    EXPORTING
      URL                = L_URL
    IMPORTING
      CLIENT             = L_HTTP_CLIENT
    EXCEPTIONS
      ARGUMENT_NOT_FOUND = 1
      PLUGIN_NOT_ACTIVE  = 2
      INTERNAL_ERROR     = 3
      OTHERS             = 4 .

 CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
      EXPORTING NAME  = 'Accept'
                VALUE = 'text/xml'.

 CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
    EXPORTING NAME  = '~request_method'
               VALUE = 'POST' .

 CALL METHOD L_HTTP_CLIENT->REQUEST->SET_CONTENT_TYPE
    EXPORTING CONTENT_TYPE  = 'application/x-www-form-urlencoded' .

 IF L_PARAMS_STRING IS NOT INITIAL.
   CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
     EXPORTING
         TEXT   = L_PARAMS_STRING
     IMPORTING
           BUFFER = L_PARAMS_XSTRING
     EXCEPTIONS
        FAILED = 1
        OTHERS = 2.

 CALL METHOD L_HTTP_CLIENT->REQUEST->SET_DATA
    EXPORTING DATA  = L_PARAMS_XSTRING  .
 ENDIF.

  CALL METHOD L_HTTP_CLIENT->SEND
    EXCEPTIONS
      HTTP_COMMUNICATION_FAILURE = 1
      HTTP_INVALID_STATE         = 2.

    CALL METHOD L_HTTP_CLIENT->RECEIVE
      EXCEPTIONS
        HTTP_COMMUNICATION_FAILURE = 1
        HTTP_INVALID_STATE         = 2
        HTTP_PROCESSING_FAILED     = 3.

 CALL METHOD L_HTTP_CLIENT->RESPONSE->GET_CDATA
        RECEIVING DATA = L_RESULT .

Please help.

Regards,

Amey

1 REPLY 1

Amey-Mogare
Contributor
0 Kudos
68

I resolved it myself by setting correct request attributes in HTTP_CLIENT object.

"Content-type", "text/xml; charset=ISO-8859-1"