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;
 }
 //29260
 //$arrCodSiorg = array('17125', '17125', '29260', '29260');
 $arrCodSiorg = array('17125');
 $exercicio = '2014';
 $configWs = array('wsdl_url' => 'https://testews.siop.gov.br/services/WSQualitativo?wsdl', 'namespace' => 'http://servicoweb.siop.sof.planejamento.gov.br/', 'usuario' => 'WS-SGDOC', 'senha' => 'eebeca4ba6657c201d96cd06bec548a1', 'perfil' => '32');
 $proxy = array('server' => false, 'port' => false, 'username' => false, 'password' => false);
 $bolUtf = false;
 foreach ($arrCodSiorg as $codigoSiorg) {
     $orgaosParametros = array('credencial' => array('perfil' => $configWs['perfil'], 'senha' => $configWs['senha'], 'usuario' => $configWs['usuario']), 'exercicio' => $exercicio, 'codigoSiorg' => $codigoSiorg);
     echo "\n\nBuscando o orgao: {$codigoSiorg}, " . ($bolUtf ? 'com' : 'sem') . " UTF8\n\n";
     echo "Criando cliente para o WebService {$configWs['wsdl_url']}.....";
     $client = new nusoap_client($configWs['wsdl_url'], false, $proxy['server'], $proxy['port'], $proxy['username'], $proxy['password'], 0, 3000);
     //$client = new nusoap_client($configWs['wsdl_url'], 0, 3000 );
     //$client->setHTTPProxy($proxy['server'], $proxy['port']);
     $client->setDebugLevel(9);
     $client->setUseCURL(true);
     $client->decode_utf8 = $bolUtf;
     $bolUtf = !$bolUtf;
     testarErroNuSoap($client);
     echo "[ OK ]\n";
     echo "Chamando o método 'obterOrgaoPorCodigoSiorg(codigoSiorg={$codigoSiorg}, exercicio={$exercicio})'.....\n";
     $result = $client->call('obterOrgaoPorCodigoSiorg', $orgaosParametros, $configWs['namespace']);
     echo "Validando o retorno.....";
     testarErroNuSoap($client);
     echo "[ OK ]\n";
     echo "Obtendo registros.....";
     $registros = array();
     if (array_key_exists('registros', $result)) {
         if (isset($result['registros'][0])) {
             $registros = $result['registros'];
         } else {
Beispiel #3
0
 /**
  * 
  * @param type $params
  * @param type $hash
  * @return boolean
  */
 private function getPrecoNusoap($params, $hash)
 {
     require_once 'vendor/lib/nusoap.php';
     $nusoap = new nusoap_client($this->_urlWebservice, 'wsdl');
     $nusoap->setUseCURL(true);
     $result = $nusoap->call("CalcPreco", $params);
     if (intval($result['CalcPrecoResult']['Servicos']['cServico']['Erro']) !== 0) {
         $this->setCache($hash, false);
         return false;
     } else {
         return (double) str_replace(",", ".", $result['CalcPrecoResult']['Servicos']['cServico']['Valor']);
     }
 }
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;
}