我是PL / SOL的新手,我正在尝试从oracle调用带有参数和发送消息的web服务...实际上,如果我传递英文值,但是对于阿拉伯语来说,它正常工作带问号的留言???? 。 我试图更改我的内容类型,但除了以下内容之外没有任何工作:
UTL_HTTP.set_header(l_http_request,' Content-Type',' application / x-www-form-urlencoded; charset = windows-1256');
在阿拉伯语中有同样的问题。你能给我一个提示吗?以下是我的代码。
注意:如果我通过调用同一个Web服务从.net客户端传递参数,则消息将以阿拉伯语正确发送。 谢谢
PROCEDURE HIMS_SEND_SMS (username Varchar2 ,
password varchar2,
phone varchar2,
code varchar2,
message varchar2,
P_RESPONSE OUT VARCHAR2) AS
l_param_list VARCHAR2(512);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response_text VARCHAR2(32767);
soap_request VARCHAR2(1024);
i integer;
BEGIN
dbms_output.enable(100000);
utl_http.set_transfer_timeout(300);
l_param_list := 'username='|| username ||chr(38)|| 'password='|| password ||chr(38)|| 'phone='|| phone ||chr(38)|| 'code='|| code ||chr(38)|| 'message='|| message;
l_http_request := UTL_HTTP.begin_request ('http://serviceexample.com/service.asmx/SendSMSHTTP'
, 'POST'
, 'HTTP/1.1');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/x-www-form-urlencoded; charset=windows-1256');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/plain; charset=windows-1256');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/soap+xml; charset=ISO-8859-6');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml; charset=UTF-8');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml; charset=ASCII');
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_param_list));
UTL_HTTP.write_text(l_http_request, l_param_list);
l_http_response := UTL_HTTP.get_response(l_http_request);
UTL_HTTP.read_text(l_http_response, l_response_text);
-- l_response_text:= substr(l_response_text,92,1);
P_RESPONSE := l_response_text;
UTL_HTTP.end_response(l_http_response);
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN UTL_HTTP.end_response(l_http_response);
END HIMS_SEND_SMS;
答案 0 :(得分:0)
我使用过汉字,我遇到了同样的问题。将body charset设置为UTF-8解决了它。并且,将长度更改为LENGTHB。试试这个:
PROCEDURE HIMS_SEND_SMS (username Varchar2 ,
password varchar2,
phone varchar2,
code varchar2,
message varchar2,
P_RESPONSE OUT VARCHAR2) AS
l_param_list VARCHAR2(512);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response_text VARCHAR2(32767);
soap_request VARCHAR2(1024);
i integer;
BEGIN
dbms_output.enable(100000);
utl_http.set_transfer_timeout(300);
l_param_list := 'username='|| username ||chr(38)|| 'password='|| password ||chr(38)|| 'phone='|| phone ||chr(38)|| 'code='|| code ||chr(38)|| 'message='|| message;
l_http_request := UTL_HTTP.begin_request ('http://serviceexample.com/service.asmx/SendSMSHTTP'
, 'POST'
, 'HTTP/1.1');
UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/x-www-form-urlencoded; charset=windows-1256');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/plain; charset=windows-1256');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/soap+xml; charset=ISO-8859-6');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml; charset=UTF-8');
--UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml; charset=ASCII');
--Change to LENGTHB here
UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTHB(l_param_list));
--change charset:
UTL_HTTP.set_body_charset(l_http_request, 'UTF-8');
UTL_HTTP.write_text(l_http_request, l_param_list);
l_http_response := UTL_HTTP.get_response(l_http_request);
UTL_HTTP.read_text(l_http_response, l_response_text);
-- l_response_text:= substr(l_response_text,92,1);
P_RESPONSE := l_response_text;
UTL_HTTP.end_response(l_http_response);
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN UTL_HTTP.end_response(l_http_response);
END HIMS_SEND_SMS;
的更多信息