1CREATE OR REPLACE FUNCTION add_numbers (p_int_1 IN NUMBER,
2 p_int_2 IN NUMBER)
3 RETURN NUMBER
4AS
5 l_clob CLOB;
6 l_result VARCHAR2(32767);
7BEGIN
8
9 -- Get the XML response from the web service.
10 l_clob := APEX_WEB_SERVICE.make_rest_request(
11 p_url => 'http://oracle-base.com/webservices/add-numbers.php',
12 p_http_method => 'GET',
13 p_parm_name => APEX_UTIL.string_to_table('p_int_1:p_int_2'),
14 p_parm_value => APEX_UTIL.string_to_table(p_int_1 || ':' || p_int_2)
15 );
16
17 -- Display the whole document returned.
18 DBMS_OUTPUT.put_line('l_clob=' || l_clob);
19
20 -- Pull out the specific value of interest.
21 l_result := APEX_WEB_SERVICE.parse_xml(
22 p_xml => XMLTYPE(l_clob),
23 p_xpath => '//answer/number/text()'
24 );
25
26 DBMS_OUTPUT.put_line('l_result=' || l_result);
27
28 RETURN TO_NUMBER(l_result);
29END;
30/