<?php /** * GBIF UDDI BioCASE CORM * * @version $Id: server.php,v 1.21 2006/08/21 09:24:10 ggiunta Exp $ **/ // give user a chance to see the source for this server instead of running the services if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource'])) { highlight_file(__FILE__); die(); } include("xmlrpc.inc"); include("xmlrpcs.inc"); include("xmlrpc_wrappers.inc"); /** * Used to test usage of object methods in dispatch maps */ class xmlrpc_server_methods_container { /* * Method used to test logging of php warnings generated by user functions. */ function phpwarninggenerator($m) { $a = $b; // this triggers a warning in E_ALL mode, since $b is undefined return new xmlrpcresp(new xmlrpcval(1, 'boolean')); } } $getgbifservices_sig=array(array($xmlrpcInt)); $getgbifservices_doc='Show list of GBIF services. Takes max number of services or 0 for unlimited.'; function getgbifservices($m) { $max=999; // start the real thing define('PGCLIENTENCODING','UNICODE'); $dbconn = pg_connect("host=192.168.1.17 dbname=corm_v2 user=WebUser"); if (!$dbconn) { echo "An error occured connecting to the CORM database."; exit; } $sql="SELECT datasource.name, uddi_service_key, access_point, provider.name, wrapper_software FROM registry.datasource JOIN registry.provider ON provider_fk=provider_id ORDER BY provider_fk LIMIT ".$max; $result = pg_query($dbconn, $sql); if (!$result) { echo "An error occured in your SQL.\n"; exit; } // create the output value $v=new xmlrpcval(); $outAr=array(); while ($row = pg_fetch_row($result)) { // recreate each struct element $outAr[]=new xmlrpcval(array("name" => new xmlrpcval("N/A"), "uddi_service_key" => new xmlrpcval(trim($row[1])), "access_point" => new xmlrpcval(trim($row[2])), "provider" => new xmlrpcval("N/A")), "struct"); } // add this array to the output value $v->addArray($outAr); return new xmlrpcresp($v); } $o=new xmlrpc_server_methods_container; $a=array( "gbif.getgbifservices" => array( "function" => "getgbifservices", "signature" => $getgbifservices_sig, "docstring" => $getgbifservices_doc ) ); $s=new xmlrpc_server($a, false); $s->setdebug(3); $s->compress_response = false; // out-of-band information: let the client manipulate the server operations. // we do this to help the testsuite script: do not reproduce in production! if (isset($_GET['RESPONSE_ENCODING'])) $s->response_charset_encoding = $_GET['RESPONSE_ENCODING']; $s->service(); // that should do all we need! ?>