-
-
Save alisson04/e2dbcac45877618847037c28737bcbf4 to your computer and use it in GitHub Desktop.
Consumindo WebService e exibindo resultado
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//link do webService | |
$wsdl = "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl"; | |
//Cria cliente | |
$client = new SoapClient($wsdl); | |
//Chama uma função passando parametros | |
$teste = $client->consultaCEP(array('cep'=>'39470000')); | |
//Exibe a estrutura do resultado | |
if ($teste != ''){ | |
echo "<pre>"; | |
print_r($teste); | |
echo "</pre>"; | |
}else{ | |
echo "erros ao se conectar no webservice!"; | |
exit(); | |
} | |
//Converte o primeiro OBJ em array | |
$tes = get_object_vars($teste); | |
//Converte o segundo OBJ em array | |
$tes = get_object_vars($tes['return']); | |
//Exite um item do resultado | |
echo $tes['cep']; | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment