Skip to content

Instantly share code, notes, and snippets.

@alisson04
Created July 16, 2018 19:18
Show Gist options
  • Save alisson04/e2dbcac45877618847037c28737bcbf4 to your computer and use it in GitHub Desktop.
Save alisson04/e2dbcac45877618847037c28737bcbf4 to your computer and use it in GitHub Desktop.
Consumindo WebService e exibindo resultado
//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