直接上程序,程序可以直接运行,只要修改IP地址和post参数就可以:
DECLARE
req utl_http.req;
resp utl_http.resp;
l_clob CLOB;
l_buf_raw RAW(10000);
amount NUMBER := 9000;
VALUE VARCHAR2(1000);
l_process VARCHAR2(20);
l_req_blob BLOB;
l_buf_len_std NUMBER := 900;
l_buf_len_cur NUMBER;
l_bod_len NUMBER;
BEGIN
req := utl_http.begin_request('http://159.77.226.31/logincheck.asp', 'POST');
utl_http.set_header(req, 'Content-Type','application/x-www-form-urlencoded'); --该参数代表请求包含POST数据
utl_http.set_header(req, 'Keep-Alive', ' timeout=1');--该参数代表超时
dbms_lob.createtemporary(lob_loc => l_clob, cache => TRUE);
l_clob := 'muser=32323&&passwd=232323&&x=33&&y=17';--POST参数的内容,格式为:变量=值&变量=值
dbms_lob.createtemporary(lob_loc => l_req_blob, cache => TRUE);
heb_lob_pub.clob2blob(p_clob => l_clob, x_blob => l_req_blob,
p_cset_f => 'utf8', p_cset_t => 'utf8');
utl_http.set_header(req, 'Content-Length', dbms_lob.getlength(l_req_blob));--该参数代表我发送的POST报文多长,不可少
utl_http.write_raw(req, l_req_blob);
resp := utl_http.get_response(req);
LOOP
utl_http.read_line(resp, VALUE, TRUE);
dbms_output.put_line(VALUE);
END LOOP;
utl_http.end_response(resp);
utl_http.end_request(req);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
WHEN OTHERS THEN
utl_http.end_response(resp);
utl_http.end_request(req);
END;
转载于:https://blog.51cto.com/snans/1345853