Location: PHPKode > projects > OpenBizMap > obm2007.1/mydata/script/odb_service.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

define('cfg_system_path', getcwd().'/odb_www');

global $context_inputs;
global $context_params;
$context_inputs='';
$context_params='';
$_odb_import_username='';

include(cfg_data_path.'/script/inc_functions.txt');
include(cfg_data_path.'/script/inc_data.txt');

$search=get('search');
$bag=get('bag');
$lastbag=get('lastbag');
$choosebag=get('choosebag');
$id=get('id');
$run=get('run');
$sys=get('sys');
$mask=get('mask');
$script=get('script');
$sys_comment=get('sys_comment');

$search=trim($search);
$search=str_replace('  ',' ',$search);
$search=str_replace('  ',' ',$search);
$search=str_replace('  ',' ',$search);
$search=str_replace('  ',' ',$search);

define('ODBSCRIPT',cfg_data_path.'/script/sys_'.$sys.'.txt');

include(cfg_data_path.'/script/sec_basic.txt');
include(cfg_data_path.'/script/nusoap.php');

if(isset($_SERVER["HTTPS"]))
  $link='https://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
else
  $link='http://'.$_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];

$NAMESPACE = str_replace('/odb_service.php','',$link);

$server = new soap_server;

$server->debug_flag=false;
$server->configureWSDL('OpenDatabag', $NAMESPACE);
$server->wsdl->schemaTargetNamespace = $NAMESPACE;

// ==== WSDL TYPES DECLARATION ==============================================

// ---- Variable -------------------------------------------------------------
$server->wsdl->addComplexType(
    'Variable',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'name' => array('name'=>'name','type'=>'xsd:string'),
        'value' => array('name'=>'value','type'=>'xsd:string')
    )
);

// ---- Record -------------------------------------------------------------

$server->wsdl->addComplexType(
    'Record',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Variable[]')
    )
);
// ---- Record[] -------------------------------------------------------------
$server->wsdl->addComplexType(
    'RecordArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Record[]')
    )
);

// ==== WSDL METHODS REGISTRATION ===========================================

$server->register(
    'doSearch',
    array('query'=>'xsd:string', 'filter'=>'xsd:string', 'key'=>'xsd:string'),
    array('return'=>'tns:RecordArray'),
    $NAMESPACE);

// ==== PROCESS REQUEST =====================================================

$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])
                        ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($HTTP_RAW_POST_DATA);
exit();


// ==== METHOD IMPLEMENTATION ===============================================

function doSearch($query,$filter,$key)
{
  if($key=='jasdhfiw12')
  {
    $record_array=search($query);

    $new_record_array=array();
    for($ii=0;$ii<sizeof($record_array);$ii++)
    {
      $variable_array=$record_array[$ii];

      $variable_cnt=0;
      reset($variable_array);
      while(list($key,$value)=each($variable_array))
      {
        if($filter=='' or strpos('_'.$filter,$key)>0)
        {
          $new_record_array[$ii][$variable_cnt]['name']=$key;
          $new_record_array[$ii][$variable_cnt]['value']=$value['value'];
          $variable_cnt++;
        }
      }
    }
  }
  return $new_record_array;
}


?>
Return current item: OpenBizMap