PL/SQL XML-RPC Implementation

Back to the list of Downloadable Software

News

  • Mar 03, 2007 - Initial release

Description

This module implements the client portion of the XML-RPC HTTP remote procedure call mechanism in Oracle's PL/SQL language. The package depends on Oracle XMLDB, and has been tested with Oracle 9ir2 and Oracle 10g.

This software was produced for Washtenaw Community College, of Washtenaw County, Michigan. Thanks to Mike Aldritch, Patrick Bracco, Amin Ladha, Kam Gill, and others at WCC for commissioning this software and allowing it to be released as Free Software.

Example

The following code example shows how to construct an XML-RPC call, dispatch the call, and process the results using the package.


create or replace package moodle_rpc as
function add_moodle_course(name in varchar2, 
description in varchar2) return varchar2;
end;
/
create or replace package body moodle_rpc as
function add_moodle_course(name in varchar2, 
description in varchar2) return varchar2
is
xml_req  xmlrpc.request;
xml_resp xmlrpc.response;
result_params xmlrpc.x_response_param_array;
result_code varchar2(50);
x_host varchar2(100) := 'xmlrpc.server.my.org';
x_port int := 80;
x_uri varchar2(300) := '/moodle/moodle_enrollment_rpc.php';
x_user varchar2(50) := 'uname';
x_pass varchar2(100) := 'password';
x_secure boolean := false;
param_val clob;
begin
xmlrpc.set_trace('all', 1); /* enable global tracing */
xml_req := xmlrpc.new_request('add_moodle_course');
xmlrpc.add_parameter(xml_req, 'name', 'string', name);
xmlrpc.add_parameter(xml_req, 'desc', 'string', description);
xml_resp := xmlrpc.invoke( xml_req,
x_host,
null /* x_port */,
x_uri,
null /* x_user */,
x_pass,
x_secure);
result_code := xmlrpc.parse_response(xml_resp, 
result_params);
if(result_code <> 'fault')
then
if(result_params(1).xrpt_type = 'array')
then
declare
arr_resp xmlrpc.response;
arr_params xmlrpc.x_response_param_array;
begin
arr_resp.doc := result_params(1).xrpt_value;
result_code := xmlrpc.parse_array(arr_resp, arr_params);
result_code := xmlrpc.get_param_value_clob(arr_params, 
2, param_val);
end;
else
result_code := xmlrpc.get_param_value_clob(result_params, 1, param_val);
end if;
dbms_output.put_line('decoded result: ' || param_val);
end if;
return 'woot (done)';
end;
begin
utl_http.set_persistent_conn_support(true);
end;
/
show errors
set serveroutput on
exec dbms_output.put_line(moodle_rpc.add_moodle_course('nameofcourse', 'hunthewumpus'));



Known Issues

Some versions of Oracle 10g XMLDB may have a bug (acknowledged by the vendor) that prevents this package from being used in Oracle Forms applications.

Links

XML-RPC Home Page

License

This PL/SQL XML-RPC package is released under the GNU Lesser General Public License (LGPL).

Copyright

Copyright (C) 2007 The Linux Box Corporation

Authors

Matt Benjamin

Installation


  1. Rename the file to remove the .txt extension (eg, mv xmlrpc_v1.sql.txt xmlrpc_v1.sql)

  2. Compile the PL/SQL file in the usual manner (eg, in SQL*Plus, '@xmlrpc.sql').



Download

xmlrpc_v1.sql.txt (45.95 Kb)