<?php
namespace Helpers\Webservice;

class MagicDispatcher extends Soap
{
    protected $call;

    public function __construct($wsdl, $name, &$envoi, $retourIsArray = true, $async = false, $prgName = 'APPEL_PHP_CENTRAL', $appName = 'Oxaproc', $NOS = 1, $vers = 1)
    {
       
        $envoi = base64_decode(urldecode($envoi));
        parent::__construct($this->wsdlUrl() . $wsdl);
        //return $client->call($name, $envoi, 'http://tempuri.org', '', false, null, 'rpc', 'UTF-8');
        if ($async) {
            $this->setModeASynchrone(true);
        }
        
        $this->call =  $this->call($name, $envoi, $retourIsArray, $prgName, $appName, $NOS, $vers);
    }

    
    /**
     * Fonction permettant d'obtenir le chemin o� l'on trouve les Web Services
     *
     * @return  string
     */
    public function wsdlUrl()
    {
        if (array_key_exists('wsdlurl', $_SESSION)) {
            return $_SESSION['wsdlurl'];
        }
            $ret = '';
            return $ret;
    }

    public function getResult():string
    {
        return $this->responseData;
    }
}
