Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/01/2012, 15:10
Avatar de RIVERMILLOS
RIVERMILLOS
 
Fecha de Ingreso: marzo-2010
Mensajes: 1.336
Antigüedad: 14 años, 2 meses
Puntos: 15
Duda con web service.

Hola tengo el siguiente web service que tiene "dos servicios " pero quisiera saber si esta bien hecho o tengo algo mal pues aveces funciona no siempre entonces quisiera saber si es por culpa de mi codigo o no?

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 != )
                {

                    
$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