From af005d4e06a1929e6564f22ea6a4fb4da8a34472 Mon Sep 17 00:00:00 2001 From: eaolson <eaolson@gmail.com> Date: Sun, 17 Jun 2018 14:53:47 -0500 Subject: [PATCH] Fix issue 28 Raise error if cannot be converted to XML. --- ora/flex_ws_api.pkb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ora/flex_ws_api.pkb b/ora/flex_ws_api.pkb index eea66d9..a2012a3 100755 --- a/ora/flex_ws_api.pkb +++ b/ora/flex_ws_api.pkb @@ -260,6 +260,7 @@ is l_hdr_value varchar2(1024); l_hdr header; l_hdrs header_table; + l_returnvalue xmltype; begin -- determine database characterset, if not AL32UTF8, conversion will be necessary @@ -389,13 +390,17 @@ begin end; utl_http.end_response(l_http_resp); + + begin + l_returnvalue := xmltype.createxml( l_clob ); + exception when others then + if sqlcode = -31011 then -- invalid xml + raise_application_error( -20001, 'HTTP response could not be converted to XML. Response was (first 1000 characters): ' || dbms_lob.substr( l_clob, 1000 )); + end if; + end; + dbms_lob.freetemporary( l_clob ); - return xmltype.createxml(l_clob); - -exception when others then - if sqlcode = -31011 then -- its not xml - return null; - end if; + return l_returnvalue; end make_request; function make_rest_request(