configureWSDL('funcionwsdl', 'urn:funcionwsdl'); // Put the WSDL schema types in the namespace with the tns prefix $server->wsdl->schemaTargetNamespace = 'urn:funcionwsdl'; // Register the data structures used by the service /*DECLARACION DE ESTRUCTURAS DE DATOS*/ /*Estructura de la funcion ase_validarUsuario*/ $server->wsdl->addComplexType( 'LoginInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'clave' => array('name' => 'clave', 'type' => 'xsd:string') ) ); /*Estructura de la funcion ase_validarUsuario_pte*/ $server->wsdl->addComplexType( 'LoginInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'token' => array('name' => 'token', 'type' => 'xsd:string') ) ); /*Estructura de la funcion ase_agregarUsuario*/ $server->wsdl->addComplexType( 'LoginInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'token' => array('name' => 'token', 'type' => 'xsd:string'), 'nombre' => array('name' => 'nombre', 'type' => 'xsd:string'), 'apellido' => array('name' => 'apellido', 'type' => 'xsd:string'), 'email' => array('name' => 'email', 'type' => 'xsd:string'), 'clave' => array('name' => 'clave', 'type' => 'xsd:string') ) ); /*Estructura de la funcion ase_validarUsuario*/ $server->wsdl->addComplexType( 'LoginOutput', 'complexType', 'struct', 'all', '', array( 'cod_error' => array('name' => 'cod_error', 'type' => 'xsd:int'), 'des_error' => array('name' => 'des_error', 'type' => 'xsd:string'), 'id_perfil' => array('name' => 'id_perfil', 'type' => 'xsd:int'), 'perfil' => array('name' => 'perfil', 'type' => 'xsd:string'), 'nombre' => array('name' => 'nombre', 'type' => 'xsd:string'), 'apellido' => array('name' => 'apellido', 'type' => 'xsd:string'), 'id_empresa' => array('name' => 'id_empresa', 'type' => 'xsd:int'), 'empresa' => array('name' => 'empresa', 'type' => 'xsd:string') ) ); /*Estructura de la funcion ase_consultarAcciones*/ $server->wsdl->addComplexType( 'ComponentInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'componente' => array('name' => 'componente', 'type' => 'xsd:int') ) ); /*Estructura de la funcion ase_consultarAcciones*/ $server->wsdl->addComplexType( 'ComponentOutput', 'complexType', 'struct', 'all', '', array( 'id_componente' => array('name' => 'id_componente', 'type' => 'xsd:int'), 'id_tipo_componente' => array('name' => 'id_tipo_componente', 'type' => 'xsd:int'), 'componente' => array('name' => 'componente', 'type' => 'xsd:string'), 'pagina' => array('name' => 'pagina', 'type' => 'xsd:string'), 'carpeta' => array('name' => 'carpeta', 'type' => 'xsd:string'), 'orden' => array('name' => 'orden', 'type' => 'xsd:int'), ) ); /*Estructura de la funcion ase_consultarAcciones*/ $server->wsdl->addComplexType( 'ComponentArray', 'complexType', 'array', '', 'SOAP-ENC:Array', array(), array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:ComponentOutput[]')), 'tns:ComponentOutput' ); /*Estructura de la funcion ase_validarComponente*/ $server->wsdl->addComplexType( 'ValidaComponenteInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'componente' => array('name' => 'componente', 'type' => 'xsd:int') ) ); /*Estructura de la funcion ase_validarComponente*/ $server->wsdl->addComplexType( 'ValidaComponenteOutput', 'complexType', 'struct', 'all', '', array( 'valida' => array('name' => 'valida', 'type' => 'xsd:boolean'), ) ); /*Estructura de la funcion ase_registrarLog*/ $server->wsdl->addComplexType( 'RegistrarLogInput', 'complexType', 'struct', 'all', '', array( 'usuario' => array('name' => 'usuario', 'type' => 'xsd:string'), 'componente' => array('name' => 'componente', 'type' => 'xsd:int'), 'accion' => array('name' => 'accion', 'type' => 'xsd:string'), 'detalle' => array('name' => 'detalle', 'type' => 'xsd:string'), 'ip' => array('name' => 'ip', 'type' => 'xsd:string') ) ); /*Estructura de la funcion ase_registrarLog*/ $server->wsdl->addComplexType( 'RegistrarLogOutput', 'complexType', 'struct', 'all', '', array( 'respuesta' => array('name' => 'respuesta', 'type' => 'xsd:boolean') ) ); /***********REGISTRO DE FUNCIONES***********/ /*Registro de la funcion ase_validarUsuario*/ $server->register( 'ase_validarUsuario', // method name array('loginInput' => 'tns:LoginInput'), // input parameters array('return' => 'tns:LoginOutput'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/hello', // soapaction 'rpc', // style 'encoded', // use 'Funcion para validar si existe el usuario y password de la base de datos' // documentation ); /*Registro de la funcion ase_validarUsuario*/ $server->register( 'ase_validarUsuario_pte', // method name array('loginInput' => 'tns:LoginInput'), // input parameters array('return' => 'tns:LoginOutput'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/hello', // soapaction 'rpc', // style 'encoded', // use 'Funcion para validar si existe el usuario y password de la base de datos' // documentation ); /*Registro de la funcion ase_validarUsuario*/ $server->register( 'ase_agregarUsuario', // method name array('loginInput' => 'tns:LoginInput'), // input parameters array('return' => 'tns:LoginOutput'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/hello', // soapaction 'rpc', // style 'encoded', // use 'Funcion para agregar nuevos usuario al adm2 con origen en el adm1' // documentation ); /*Registro de la funcion ase_consultarAcciones*/ // Register the method to expose $server->register( 'ase_consultarAcciones', // method name array('componentInput' => 'tns:ComponentInput'), // input parameters array('return' => 'tns:ComponentArray'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/component', // soapaction 'rpc', // style 'encoded', // use 'Funcion para retornar los componentes de acuerdo a un usuario' // documentation ); /*Registro de la funcion ase_validarComponente*/ $server->register( 'ase_validarComponente', // method name array('validaComponenteInput' => 'tns:ValidaComponenteInput'), // input parameters array('return' => 'tns:ValidaComponenteOutput'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/hello', // soapaction 'rpc', // style 'encoded', // use 'Funcion para validar si existe el usuario y password de la base de datos' // documentation ); /*Registro de la funcion ase_registrarLog*/ $server->register( 'ase_registrarLog', // method name array('registrarLogInput' => 'tns:RegistrarLogInput'), // input parameters array('return' => 'tns:RegistrarLogOutput'), // output parameters 'urn:funcionwsdl', // namespace 'urn:funcionwsdl/hello', // soapaction 'rpc', // style 'encoded', // use 'Funcion para registrar el log en la base de datos' // documentation ); /*******************FUNCIONES*************/ function ase_validarUsuario($loginInput) { global $conectar; $db = pg_connect($conectar); $sql = "select cod_error, des_error, id_perfil, perfil, nombre, apellido, id_empresa, empresa from ase.ase_login ('".$loginInput['usuario']."', '".$loginInput['clave']."')"; $rs = pg_exec($db,$sql); $row = pg_fetch_array ($rs, $i); $cod_error = $row['cod_error']; $des_error = $row['des_error']; $id_perfil = $row['id_perfil']; $perfil = $row['perfil']; $nombre = $row['nombre']; $apellido = $row['apellido']; $id_empresa = $row['id_empresa']; $empresa = $row['empresa']; pg_close($db); return array( 'cod_error' => $cod_error, 'des_error' => $des_error, 'id_perfil' => $id_perfil, 'perfil' => $perfil, 'nombre' => $nombre, 'apellido' => $apellido, 'id_empresa' => $id_empresa, 'empresa' => $empresa ); } function ase_agregarUsuario($loginInput) { if ($loginInput['token'] == '11efb850321509b135f1eed2847b8bf4') { global $conectar; $db = pg_connect($conectar); $sql = "select * from ase.crea_usuario('". $loginInput['usuario'] . "', '". $loginInput['clave'] ."', '". $loginInput['nombre'] ."', '". $loginInput['apellido'] ."', '". $loginInput['email'] ."', 19, 1,'adm1' )"; $rs = pg_exec($db,$sql); pg_close($db); } return array( 'proceso' => 'completo' ); } function ase_validarUsuario_pte($loginInput) { if ($loginInput['token'] != '11efb850321509b135f1eed2847b8bf4') { return array( 'cod_error' => 2, 'des_error' => 'ilegal login', 'id_perfil' => '', 'perfil' => '', 'nombre' => '', 'apellido' => '', 'id_empresa' => '', 'empresa' => '' ); } global $conectar; $db = pg_connect($conectar); $sql = "select cod_error, des_error, id_perfil, perfil, nombre, apellido, id_empresa, empresa from ase.ase_login_bridge ('".$loginInput['usuario']."')"; $rs = pg_exec($db,$sql); $row = pg_fetch_array ($rs, $i); $cod_error = $row['cod_error']; $des_error = $row['des_error']; $id_perfil = $row['id_perfil']; $perfil = $row['perfil']; $nombre = $row['nombre']; $apellido = $row['apellido']; $id_empresa = $row['id_empresa']; $empresa = $row['empresa']; pg_close($db); return array( 'cod_error' => $cod_error, 'des_error' => $des_error, 'id_perfil' => $id_perfil, 'perfil' => $perfil, 'nombre' => $nombre, 'apellido' => $apellido, 'id_empresa' => $id_empresa, 'empresa' => $empresa ); } function ase_consultarAcciones($componentInput) { global $conectar; $db = pg_connect($conectar); $sql = "select id_componente, id_tipo_componente, componente, pagina, carpeta, orden from ase.ase_consulta_acciones ('".$componentInput['usuario']."', '".$componentInput['componente']."')"; $rs = pg_exec($db,$sql); $num_reg = pg_numrows($rs); $result=array(); for ($i=0; $i<$num_reg; $i++) { $result[] = pg_fetch_array ($rs); } pg_close($db); return $result; } function ase_validarComponente($validaComponenteInput) { global $conectar; $db = pg_connect($conectar); //$sql = "select cod_error, des_error, id_perfil, perfil from ase.ase_login ('".$login['usuario']."', '".$login['clave']."')"; $sql = "select * from ase.ase_perfil_componente c, ase.ase_usuario u where c.id_perfil = u.id_perfil and u.usuario = '".$validaComponenteInput['usuario']."' and c.id_componente = ".$validaComponenteInput['componente']; $rs = pg_exec($db,$sql); $row = pg_fetch_array ($rs, $i); if($row!=''){ $valida=true; } else{ $valida=false; } pg_close($db); return array( 'valida' => $valida ); } function ase_registrarLog($registrarLogInput) { global $conectar; $db = pg_connect($conectar); //$sql = "select cod_error, des_error, id_perfil, perfil from ase.ase_login ('".$login['usuario']."', '".$login['clave']."')"; $sql = "insert into ase.ase_log (id_usuario, id_componente, accion, detalle, ip) values ((select id_usuario from ase.ase_usuario where usuario='".$registrarLogInput['usuario']."'), ".$registrarLogInput['componente'].", '".$registrarLogInput['accion']."', '".$registrarLogInput['detalle']."', '".$registrarLogInput['ip']."' )"; $rs = pg_exec($db,$sql); $rows=pg_affected_rows ($rs); if($rows!=0){ $respuesta=true; } else{ $respuesta=false; } $row = pg_fetch_array ($rs, $i); pg_close($db); return array( 'respuesta' => $respuesta ); } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?>