<?php # http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx $url = 'http://ws.correios.com.br/calculador/CalcPrecoPrazo.asmx?WSDL'; $client = new SoapClient($url, ['trace' => true, 'exceptions' => true, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'connection_timeout' => 1000]); $args = new stdClass(); $args->nCdServico = "40010"; $args->sCepOrigem = "04433070"; $args->sCepDestino = "07936060"; echo "<pre>"; print_r($client->CalcPrazo($args));
private function getPrazoSoapclient($params) { try { $client = new SoapClient($this->_urlWebservice); $result = $client->CalcPrazo($params); if (intval($result->CalcPrazoResult->Servicos->cServico->Erro) !== 0) { return false; } else { return (int) $result->CalcPrazoResult->Servicos->cServico->PrazoEntrega; } } catch (Exception $e) { return false; } }