setReturnResponse(true); } public function handle($request = null) { $response = parent::handle($request); $response = str_replace( 'xmlns:ns1="http://impl.ws.application.proveedorcentro.meyss.spee.es"', 'xmlns:ns1="http://impl.ws.application.proveedorcentro.meyss.spee.es" xmlns:impl="http://impl.ws.application.proveedorcentro.meyss.spee.es" xmlns:sal="http://salida.bean.domain.common.proveedorcentro.meyss.spee.es" xmlns:ent="http://entsal.bean.domain.common.proveedorcentro.meyss.spee.es" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"', $response ); $response = $this->addNamespaceToTag($response, 'RESPUESTA_DATOS_CENTRO', 'sal'); $response = $this->addNamespaceToTag($response, 'RESPUESTA_OBT_LISTA_ACCIONES', 'sal'); $response = $this->addNamespaceToTag($response, 'RESPUESTA_ELIMINAR_ACCION', 'sal'); $response = $this->addNamespaceToTag($response, 'RESPUESTA_OBT_ACCION', 'sal'); $response = $this->addNamespaceToTag($response, 'ACCION_FORMATIVA', 'ent'); $response = $this->addNamespaceToTag($response, 'ID_ACCION', 'ent'); $response = $this->addNamespaceToTag($response, 'DATOS_IDENTIFICATIVOS', 'ent'); // Dentro de ACCION_FORMATIVA no hay ent:ID_ACCION $response = str_replace( '', '', $response ); $response = str_replace( '', '', $response ); //$response = file_get_contents('/tmp/log4.xml'); header('Content-Length:'.strlen($response)); echo $response; exit; } private function addNamespaceToTag($response, $tag, $namespace) { return str_replace( $tag, $namespace.":".$tag, $response ); } } function authenticate($WSUser, $WSKey) { $tUser = Database::get_main_table(TABLE_MAIN_USER); $tApi = Database::get_main_table(TABLE_MAIN_USER_API_KEY); $login = Database::escape_string($WSUser); $sql = "SELECT u.user_id, u.status FROM $tUser u, $tApi a WHERE u.username='".$login."' AND u.user_id = a.user_id AND a.api_service = 'dokeos' AND a.api_key='".$WSKey."'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $row = Database::fetch_row($result); if ($row[1] == '4') { //UserManager::is_admin($row[0])) { return true; } else { return false; } } else { return false; } } $doc = new DOMDocument(); $post = file_get_contents('php://input'); if (!empty($post)) { $doc->loadXML($post); $WSUser = $doc->getElementsByTagName('Username')->item(0)->nodeValue; $WSKey = $doc->getElementsByTagName('Password')->item(0)->nodeValue; $s = new WSSESoapServer($doc); if (!empty($WSUser) && !empty($WSKey)) { if (authenticate($WSUser, $WSKey)) { // pointing to the current file here $options = [ 'soap_version' => SOAP_1_1, ]; $soap = new CustomServer($wsdl, $options); $soap->setObject(new Sepe()); if ($s->process()) { $xml = $s->saveXML(); //header('Content-type: application/xml'); $soap->handle($xml); exit; } else { error_log('not processed'); } } else { error_log('Claves incorrectas'); } } else { error_log('not processed'); } } else { $contents = file_get_contents($wsdl); header('Content-type: application/xml'); echo $contents; exit; } exit;