コード例 #1
1
 /**
  * Permet de mettre en place le client de la requête en fonction du WSDL.
  *
  * @param $urlWsdl
  * @return \nusoap_client
  */
 private function setClientSoap($urlWsdl)
 {
     // Instanciation du client SOAP
     $this->client = new \nusoap_client($urlWsdl, false, false, false, false, false, 0, 1000);
     $this->client->soap_defencoding = 'UTF-8';
     $this->client->decode_utf8 = false;
     // Mise en place des options CURL
     // Option curl
     $this->client->setUseCurl(true);
     // Mise en place du SSl si on l'active
     if ($this->enabledSSL) {
         // Mise en place des données d'authentification SSL
         $certRequest = array('cainfofile' => $this->caChainClientLocation, 'sslcertfile' => $this->certClientLocation, 'sslkeyfile' => $this->privateKeyClientLocation, 'passphrase' => $this->privateKeyClientPassword);
         $this->client->setCredentials('', '', 'certificate', $certRequest);
         $this->client->setCurlOption(CURLOPT_SSLVERSION, 3);
         // @TODO : cette option sera à mettre à true. On utilisera un fichier contenant l'AC Yousign en tant que trustore
         $this->client->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
     }
     // @TODO : voir comment on lève une exception
     $err = $this->client->getError();
     if ($err) {
         echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
         echo '<h2>Debug</h2><pre>' . htmlspecialchars($this->client->getDebug(), ENT_QUOTES) . '</pre>';
         exit;
     }
     return $this->client;
 }
コード例 #2
0
 function inicializarWebService()
 {
     $proxy = array();
     $proxy['server'] = !is_null($this->proxy) ? $this->proxy->server : false;
     $proxy['port'] = !is_null($this->proxy) ? $this->proxy->port : false;
     $proxy['username'] = !is_null($this->proxy) ? $this->proxy->username : false;
     $proxy['password'] = !is_null($this->proxy) ? $this->proxy->password : false;
     $client = new nusoap_client($this->configuracao->wsdl, false, $proxy['server'], $proxy['port'], $proxy['username'], $proxy['password'], 0, 3000);
     $client->setDebugLevel(9);
     $client->setUseCURL(true);
     if (!is_null($this->certificado)) {
         if (strlen($this->certificado->crt . $this->certificado->key . $this->certificado->pem) > 0) {
             $client->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
             $client->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
             $client->authtype = 'certificate';
             if (strlen($this->certificado->crt) > 0) {
                 $client->certRequest['sslcertfile'] = $this->certificado->crt;
                 # file containing the user's certificate
             }
             if (strlen($this->certificado->key) > 0) {
                 $client->certRequest['sslkeyfile'] = $this->certificado->key;
                 # file containing the private key
             }
             if (strlen($this->certificado->pem) > 0) {
                 $client->certRequest['cainfofile'] = $this->certificado->pem;
                 # file containing the root certificate
             }
         }
     }
     $this->client = $client;
 }
コード例 #3
-22
function inicializarWebServiceSOF($configuracao)
{
    $proxy = ConfigWs::factory()->getSiopProxyConfig();
    $client = new nusoap_client($configuracao['wsdl_url'], false, $proxy['server'], $proxy['port'], $proxy['username'], $proxy['password'], 0, 3000);
    $client->setDebugLevel(9);
    $client->setUseCURL(true);
    // Verifica se há algum dado de configuração para certificado.
    // Caso houver define o tipo de autenticação para certificate.
    $certificado = ConfigWs::factory()->getSiopCertificateConfig();
    if (strlen($certificado['crt'] . $certificado['key'] . $certificado['pem']) > 0) {
        $client->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
        $client->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
        $client->authtype = 'certificate';
        if (strlen($certificado['crt']) > 0) {
            $client->certRequest['sslcertfile'] = $certificado['crt'];
            # file containing the user's certificate
        }
        if (strlen($certificado['key']) > 0) {
            $client->certRequest['sslkeyfile'] = $certificado['key'];
            # file containing the private key
        }
        if (strlen($certificado['pem']) > 0) {
            $client->certRequest['cainfofile'] = $certificado['pem'];
            # file containing the root certificate
        }
    }
    return $client;
}