Example #1
0
    /**
     * Seguridad programada completamente
     */
    function evt__form__enviar($datos)
    {
        $carpeta = dirname(__FILE__);
        //--1- Arma el mensaje	(incluyendo los headers)
        $this->s__echo = $datos;
        $clave = xml_encode($datos['clave']);
        $valor = xml_encode($datos['valor']);
        $payload = <<<XML
<ns1:test xmlns:ns1="http://siu.edu.ar/toba_referencia/serv_pruebas">
\t<texto>{$clave} {$valor}</texto>
</ns1:test>
XML;
        $mensaje = new toba_servicio_web_mensaje($payload);
        //--2- Arma el servicio indicando certificado del server y clave privada del cliente
        $cert_server = ws_get_cert_from_file($carpeta . '/servidor.crt');
        $clave_privada = ws_get_key_from_file($carpeta . "/cliente.pkey");
        $cert_cliente = ws_get_cert_from_file($carpeta . "/cliente.crt");
        $seguridad = array("sign" => true, "encrypt" => true, "algorithmSuite" => "Basic256Rsa15", "securityTokenReference" => "IssuerSerial");
        $policy = new WSPolicy(array("security" => $seguridad));
        $security_token = new WSSecurityToken(array("privateKey" => $clave_privada, "receiverCertificate" => $cert_server, "certificate" => $cert_cliente));
        $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto() . '/servicios.php/serv_seguro_codigo', 'action' => 'http://siu.edu.ar/toba_referencia/serv_pruebas/test', 'policy' => $policy, 'securityToken' => $security_token);
        $servicio = toba::servicio_web('cli_seguro', $opciones);
        //-- 3 - Muestra la respuesta
        $respuesta = $servicio->request($mensaje);
        toba::notificacion()->info($respuesta->get_payload());
    }
Example #2
0
 /**
  * Seguridad configurada en la instalacion
  */
 function evt__form__enviar($datos)
 {
     //--1- Arma el mensaje	(incluyendo los headers)
     $this->s__echo = $datos;
     $opciones = array('action' => 'test');
     $mensaje = new toba_servicio_web_mensaje($this->s__echo, $opciones);
     //--2- Arma el servicio
     $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto() . '/servicios.php/serv_seguro_configuracion');
     $servicio = toba::servicio_web('cli_seguro_configuracion', $opciones);
     //-- 3 - Muestra la respuesta
     $respuesta = $servicio->request($mensaje);
     toba::notificacion()->info(print_r($respuesta->get_array(), true));
 }
Example #3
0
    function test_servicio_eco()
    {
        $mensaje = xml_encode("Holá Mundo");
        $payload = <<<XML
<ns1:eco xmlns:ns1="http://siu.edu.ar/toba_referencia/serv_pruebas">
\t<texto>{$mensaje}</texto>
</ns1:eco>
XML;
        $opciones = array('to' => 'http://localhost/' . toba_recurso::url_proyecto($this->get_proyecto()) . '/servicios.php/serv_sin_seguridad');
        $servicio = toba::servicio_web('cli_sin_seguridad', $opciones);
        $mensaje = $servicio->request(new toba_servicio_web_mensaje($payload));
        $xml = new SimpleXMLElement($mensaje->get_payload());
        $this->AssertEqual(xml_decode((string) $xml->texto), "Respuesta: Holá Mundo");
    }
Example #4
0
 function evt__form_excepciones__enviar($datos)
 {
     $this->s__datos_excepciones = $datos;
     $opciones = array('action' => 'http://siu.edu.ar/toba_referencia/serv_pruebas/enviar_excepcion', 'to' => 'http://localhost/' . toba_recurso::url_proyecto() . '/servicios.php/serv_sin_seguridad');
     $servicio = toba::servicio_web('cli_sin_seguridad', $opciones);
     //--2- Da de alta la persona
     $mensaje = new toba_servicio_web_mensaje($this->s__datos_excepciones);
     try {
         $respuesta = $servicio->request($mensaje);
     } catch (toba_error_servicio_web $e) {
         toba::notificacion()->info($e->get_mensaje() . ' (codigo: "' . $e->get_codigo() . '")');
     }
 }