<?php
namespace Helpers\Webservice;

use Helpers\Session\ParseBase1;

class MagicDispatcher extends Soap
{
    protected mixed $call;

    /**
     * @param mixed $wsdl
     * @param mixed $name
     * @param mixed $envoi
     * @param mixed $retourIsArray
     * @param mixed $async
     * @param mixed $prgName
     * @param mixed $appName
     * @param mixed $NOS
     * @param mixed $vers
     */
    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()
    {
        return (new ParseBase1())->getPath()->wsdl;
    }

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