Código PHP:
require_once('lib/nusoap.php');
require_once('includes/Db.class.php');
$servidor = new soap_server();
$servidor->configureWSDL("Neighwsdl","urn:Neighwsdl");
$servidor->register("getNeigh",array('point_input' => 'xsd:string'),
array("return" => "xsd:string"), "urn:getNeighwsdl",
"urn:Neighwsdl#Posts",
"rpc",
"encoded",
"Trae el barrio");
$servidor->register("getSquare",array('point_shape' => 'xsd:string'),
array("return" => "xsd:string"), "urn:getNeighwsdl",
"urn:Neighwsdl#Posts",
"rpc",
"encoded",
"Trae el cuadrado");
function getNeigh($point_input)
{
try{
$conn = Db::getInstance();
$query_count="SELECT count(*) num
FROM barrios B
WHERE Contains(B.datospoligono,GeomFromText('POINT(".$point_input.")'))";
$query="SELECT idbarrio,AsText( datospoligono )poligono,nombre
FROM barrios B
WHERE Contains(B.datospoligono,GeomFromText('POINT(".$point_input.")'))";
$result_count = $conn->ejecutar($query_count);
if($result_count)
{
$res_count = $conn->obtener_fila($result_count);
if( $res_count->num != 0 )
{
$result=$conn->ejecutar($query);
if($result)
{
$res=$conn->obtener_fila($result);
return json_encode($res);
}else{
throw new Exception("Error consulta 1" . $query);
}
}else{
throw new Exception("Error consulta 2 " . $query);
}
}else{
throw new Exception("Error consulta 3" . $query_count);
}
}catch(Exception $e){
return $e->getMessage();
}
return false;
}
function getSquare($point_shape = "0 0")
{
try{
$conn = Db::getInstance();
$query_count="SELECT count(*) num
FROM shapebogota
WHERE Contains(shape,GeomFromText('POINT(".$point_shape.")'))";
$query="SELECT id_shape,AsText( shape )poligono
FROM shapebogota
WHERE Contains(shape,GeomFromText('POINT(".$point_shape.")'))";
$result_count = $conn->ejecutar($query_count);
if($result_count)
{
$res_count = $conn->obtener_fila($result_count);
if($res_count->num!=0)
{
$result = $conn->ejecutar($query);
if( $result )
{
$res = $conn->obtener_fila($result);
return json_encode($res);
}else{
throw new Exception("Error consulta " . $query);
}
}else{
throw new Exception("Error consulta " . $query);
}
}else
{
return false;
}
}catch(Exception $e)
{
return $e->getMessage();
}
}
saludos