Unable to post variables using utl_http
Hi guys I hope you can help me out.
I'm having issues posting variables using the built in package utl_http. Its installed and I can retrieve web pages but I can't post variables. I was trying to use a simple web service when I came across the problem. While trying to fix it, I have broken it right down to point where I can't go any further.
I'm currently testing it using a site called posttestserver.com. You call the url in your code (see below) and you dump your variables and it tells what it has recieved.
The following code works, it retrieves http from google.com, and I think it confirms that I can get web page info using utl_http
select utl_http.request('http://google.com') from dual
However the reply I get from the following code tells me that no variables have been read by the api. I get a similar response when trying to call a normal web service
declare
vRequest Utl_Http.req;
vPostText VARCHAR2(500);
vLogin VARCHAR2(500);
vResponse Utl_Http.resp;
--vResponseText VARCHAR2(5000);
vResponseText clob;
vErrorText clob;
v_action varchar2(20) := 'sendsms';
BEGIN
vPostText := 'par1=5'||'&'||'par2=7'||'&'||'par3=9';
utl_http.set_proxy(apex_application.g_proxy_server, NULL);
utl_http.set_persistent_conn_support(TRUE);
utl_http.set_transfer_timeout(300);
--
vRequest := Utl_Http.begin_request('http://posttestserver.com/post.php', 'POST');
--
utl_http.set_header(vRequest, 'Proxy-Connection', 'KeepAlive');
utl_http.set_header (vRequest, 'Connection', 'Keep-Alive');
--
utl_http.set_header(vRequest, 'Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
--
utl_http.write_text(vRequest, vPostText);
vResponse := utl_http.get_response(vRequest);
Utl_Http.read_text(vResponse, vResponseText);
dbms_output.put_line(vResponseText);
dbms_output.put_line(vPostText);
END ;
I'm guessing that it is something in my environment - but I've pulling my hair out with this one.
If you have any ideas that would be great. Oracle XE 10g, Application Express 4.0.1.00.03
Cheers, TIA
Ade