__dispatch_map['findLayers'] = array('in' => array('keywords' => 'string', 'servertype' => 'string', 'xmin' => 'double', 'ymin' => 'double', 'xmax' => 'double', 'ymax' => 'double'), 'out' => array('results' => '{http://soapinterop.org/xsd}OGCLayerArray') ); $this->__typedef['{http://soapinterop.org/xsd}OGCLayer'] = array( 'name'=>'string', 'title'=>'string', 'description'=>'string', 'onlineresource'=>'string', 'servertype'=>'string', 'serverversion'=>'string' ); $this->__typedef['{http://soapinterop.org/xsd}OGCLayerArray'] = array( array( '{http://soapinterop.org/xsd}OGCLayer' ) ); } function findLayers($keywords, $servertype, $xmin, $ymin, $xmax, $ymax) { require_once 'DB.php'; $results = array(); $user = 'pramsey'; $pass = 'pramsey'; $host = 'localhost'; $dbname = 'wms_google'; $dsn = "pgsql://$user:$pass@$host/$dbname"; $keywords = implode("&",explode(" ",trim($keywords))); $keywords = addslashes(trim($keywords)); # Connect to the database $db = DB::connect($dsn); if( DB::isError($db) ) { return new SOAP_Fault($db->getMessage(),'Client'); } # Execute the query $box = "POLYGON(($xmin $ymin,$xmin $ymax,$xmax $ymax,$xmax $ymin,$xmin $ymin))"; $sql = "select layer_name, layer_title, layer_abstract, onlineresource, version from wms_server_layers,wms_servers where wms_server_layers.layer_tsidx @@ '$keywords'::tsquery and layer_bbox && geometryfromtext('$box',4326) and wms_servers.id = wms_server_layers.server_id"; $result = $db->query($sql); if( DB::isError($db) ) { return new SOAP_Fault($db->getMessage(),'Client'); } # Fetch results from the database while ($row = $result->fetchRow()) { $layer = array( 'name' => $row[0], 'title' => $row[1], 'description' => $row[2], 'onlineresource' => $row[3], 'servertype' => 'WMS', 'serverversion' => $row[4] ); array_push($results,$layer); } return new SOAP_Value('results','{http://soapinterop.org/xsd}OGCLayerArray',$results); } } $webservice = new OGCSearch(); #-------------------------------------------------------------------------- # Set up the SOAP service and publish the object. $server = new SOAP_Server(); $server->addObjectMap($webservice, 'http://schemas.xmlsoap.org/soap/envelope/'); if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST') { $server->service($HTTP_RAW_POST_DATA); } else { // Create the DISCO server $disco = new SOAP_DISCO_Server($server,'OGCSearch'); header("Content-type: text/xml"); if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0) { echo $disco->getWSDL(); } else { echo $disco->getDISCO(); } } exit; ?>