I'm trying to implement a php
implementation via simplexml_load_file
to check and return data to the Post API. In this case, it is necessary to pass variables in url
. I'm doing this:
I'm doing this:
function encontraCep() {
$cep = $_POST["txtCep"];
$url = "https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl&txtCep=".$cep;
$xml = simplexml_load_file($url);
return $xml;
}
dados = encontraCep();
A simple
print "<pre>";
print_r($dados);
print "</pre>";
Return me:
SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => AtendeClienteService
[targetNamespace] => http://cliente.bean.master.sigep.bsb.correios.com.br/
)
)
Where am I going wrong?
I am following the tutorial given in link , done in asp.net
There he makes a form:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Teste WS dos Correios</h1><br />
<asp:Panel ID="Panel1" runat="server" GroupingText="Busca Endereço">
CEP:
<asp:TextBox ID="txtCep" runat="server"></asp:TextBox>&nbsp;<asp:Button ID="btnBuscarEndereco" runat="server" OnClick="btnBuscarEndereco_Click" Text="Buscar Endereço" />
<br />
<asp:Label ID="lblEndereco" runat="server"></asp:Label>
</asp:Panel>
</div>
</form>
</body>
</html>
And a function that takes the return:
protected void btnBuscarEndereco_Click(object sender, EventArgs e)
{
wsCorreio.AtendeClienteClient ws = new wsCorreio.AtendeClienteClient("AtendeClientePort"); //Verificar o nome do endpoint no arquivo Web.config
var dados = ws.consultaCEP(txtCep.Text);
if (dados != null)
{
lblEndereco.Text = string.Format(@"Endereço: {0}<br />
Complemento 1: {1}<br />
Complemento 2: {2}<br />
Bairro: {3}<br />
Cidade: {4}<br />
Estado: {5}",
dados.end,
dados.complemento,
dados.complemento2,
dados.bairro,
dados.cidade,
dados.uf);
}
else
lblEndereco.Text = "CEP não encontrado.";
}
But there is no action
in form
of it to see the sending of url
.