I have created a procedure which calls a restful web service from Oracle 11.2 server using UTL_HTTP package. It's a post request and I send an arabic value along with other data which defined as varchar2.
Arabic string is sent as "???? ????", to web service which I checked in the logging. I set the body as UTF-8 and database server character set is "AR8ISO8859P6".
I tried with convert function and all the ways possible. I could not figure out how to fix it.
Find below code.
t_request_body :=
'{
"ArabicValue":"'
|| p_arabic_value
|| '",
"EnglishValue":"'
|| p_english_value
|| '"
}';
UTL_HTTP.set_transfer_timeout (5);
t_http_req :=
UTL_HTTP.begin_request
('webservice_url',
'POST',
'HTTP/1.1'
);
/*Describe in the request-header*/
UTL_HTTP.SET_BODY_CHARSET('UTF-8');
UTL_HTTP.set_header (t_http_req, 'Content-Type', 'application/json;charset=UTF-8');
UTL_HTTP.set_header (t_http_req, 'Content-Length', LENGTH (t_request_body));
UTL_HTTP.set_header (t_http_req, 'TransactionId', t_transaction_id);
UTL_HTTP.set_header (t_http_req, 'Accept', 'application/xml');
/*Put the data in de body of the request*/
UTL_HTTP.write_text (t_http_req, t_request_body);
/*Web service call*/
t_http_resp := UTL_HTTP.get_response (t_http_req);
/*Reading transaction id from header*/
UTL_HTTP.get_header_by_name (t_http_resp, 'TransactionId', t_trans);
English value parameter is passing to web service fine. Arabic value is going as "????? ????". I tried convert function available in oracle to convert it to UTF-8. It's not working too.