Hi,
I am trying to call a web service within my company by using PL/SQL script. I was required to pass two parameters to the web service: a job name and a long XML string of sales data.
The following is the PL/SQL script I created which attempt to use post data to the web service.
/**************************************************/
DECLARE
req utl_http.req;
resp utl_http.resp;
value VARCHAR2(1024);
p_in_job_name VARCHAR2(20) := 'job_name';
p_in_sales_data VARCHAR2(4000) := '<US_SALES><US_NORTHEST><INVOICE_DATE>07/22/2013</INVOICE_DATE>.....</US_NORTHEST></US_SALES>';
BEGIN
req := utl_http.begin_request(v_url);
utl_http.set_header(req,'User-Agent','Mozilla/4.0');
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);
EXCEPTION
WHEN utl_http.end_of_body
THEN
utl_http.end_response(resp);
END;
/
/**************************************************/
Where I run it in Oracle 11g v2, I received the following error message:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""
http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
I know the same kind of script works on another web service in the company that don't have XML string as input parameters. The web service to be called also works as well.
I suspect that XML tag brackets may be creating problems as input parameter. I was told that to post XML data using a named form parameter, I might need to encode XML before it is assigned to the parameter.
I tried to google about encoding XML but couldn't find much information.
Any idea about passing XML as parameter or other insight are truly appreciated.
Nick