PhpSigep\Services\Real\SoapClientFactory::getSoapClient PHP Method

getSoapClient() public static method

public static getSoapClient ( )
    public static function getSoapClient()
    {
        if (!self::$_soapClient) {
            $wsdl = Bootstrap::getConfig()->getWsdlAtendeCliente();
            $opts = array('ssl' => array('ciphers' => 'RC4-SHA', 'verify_peer' => false, 'verify_peer_name' => false));
            // SOAP 1.1 client
            $params = array('encoding' => self::WEB_SERVICE_CHARSET, 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_1, 'trace' => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION, 'exceptions' => Bootstrap::getConfig()->getEnv() != Config::ENV_PRODUCTION, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts));
            self::$_soapClient = new \SoapClient($wsdl, $params);
        }
        return self::$_soapClient;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param \PhpSigep\Model\AbstractModel|\PhpSigep\Model\SolicitaEtiquetas $params
  *
  * @throws \PhpSigep\Services\Exception
  * @throws InvalidArgument
  * @return BuscaClienteResult
  */
 public function execute(AbstractModel $params)
 {
     if (!$params instanceof \PhpSigep\Model\AccessData) {
         throw new InvalidArgument();
     }
     $soapArgs = array('idContrato' => $params->getNumeroContrato(), 'idCartaoPostagem' => $params->getCartaoPostagem(), 'usuario' => $params->getUsuario(), 'senha' => $params->getSenha());
     $result = new Result();
     try {
         if (!$params->getUsuario() || !$params->getSenha() || !$params->getNumeroContrato() || !$params->getCartaoPostagem()) {
             throw new Exception('Para usar este serviço você precisa setar o nome de usuário, a senha, o numero ' . 'do contrato e o número do cartão de postagem.');
         }
         $r = SoapClientFactory::getSoapClient()->buscaCliente($soapArgs);
         if (!$r || !is_object($r) || !isset($r->return) || $r instanceof \SoapFault) {
             if ($r instanceof \SoapFault) {
                 throw $r;
             }
             throw new \Exception('Erro ao consultar os dados do cliente. Retorno: "' . $r . '"');
         }
         $result->setResult(new BuscaClienteResult((array) $r->return));
     } catch (\Exception $e) {
         if ($e instanceof \SoapFault) {
             $result->setIsSoapFault(true);
             $result->setErrorCode($e->getCode());
             $result->setErrorMsg(SoapClientFactory::convertEncoding($e->getMessage()));
         } else {
             $result->setErrorCode($e->getCode());
             $result->setErrorMsg($e->getMessage());
         }
     }
     return $result;
 }
All Usage Examples Of PhpSigep\Services\Real\SoapClientFactory::getSoapClient