2011 Jul 18 7:23 AM
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
2011 Aug 02 8:08 AM
I resolved it myself by setting correct request attributes in HTTP_CLIENT object.
"Content-type", "text/xml; charset=ISO-8859-1"