Boa Tarde, já tentei de varias maneira gera uma Nfse ou consultar. Você pode me ajudar.
Segue os dois códigos.
//Gerar Nota
<?php
// ambiente de produção
$wsdl = "https://sim.digifred.net.br/frederico/nfse/ws/principal/wsdl";
// ambiente em testes
// $wsdl = "https://sim.digifred.net.br/frederico_homolog/nfse/ws/principal/wsdl";
$arquivoAssinado = 'nota.xml';
$XmlAssinado = htmlentities(file_get_contents($arquivoAssinado));
$cabecalho = htmlentities('<cabecalho versao="2.00" xmlns="http://www.abrasf.org.br/nfse.xsd"><versaoDados>2.00</versaoDados></cabecalho>');
$envelope =
'<?xml version="1.0" encoding="UTF-8"?>
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmln s:ser="http://services.nfse">
<x:Header/>
<x:Body>
<ser:GerarNfseRequest>
<nfseCabecMsg>' . $cabecalho . '</nfseCabecMsg>
<nfseDadosMsg>' . $XmlAssinado . '</nfseDadosMsg>
</ser:GerarNfseRequest>
</x:Body>
</x:Envelope>';
$headers = array(
"Content-type: text/xml; charset=utf-8",
"SOAPAction: http://services.nfse/GerarNfseEnvio",
"Content-length: " . strlen($envelope),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $wsdl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $envelope);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$html = utf8_decode(curl_exec($ch));
file_put_contents("$arquivoAssinado.ret", $html);
curl_close($ch);
var_dump($ch);
preg_match_all('/<outputXML>(.*?)<\/outputXML>/s', $html, $matches);
$response = html_entity_decode(count($matches) && count($matches[1]) ? $matches[1][0] : $html);
var_dump($response);
?>
-------------------------------------------------------------------------
//Consultar nota
<?php
// ambiente de produção
$wsdl = "https://sim.digifred.net.br/frederico/nfse/ws/principal/wsdl";
// ambiente em testes
// $wsdl = "https://sim.digifred.net.br/frederico_homolog/nfse/ws/principal/wsdl";
$client = new SoapClient($wsdl);
$function = 'ConsultarNfsePorFaixa';
$arguments = array('ConsultarNfseFaixaEnvio' => array(
'Prestador' => array(
'CpfCnpj' => array(
'Cnpj' => 21045325000160,
),
'InscricaoMunicipal' => 80729,
),
'Faixa' => array(
'NumeroNfseInicial' => 202000000000001,
'NumeroNfseFinal' => 202000000000005,
),
'Pagina' => 1
));
$entrada = array(
'nfseCabecMsg' => array('versaoDados' =>'1.0'),
'nfseDadosMsg' => $arguments);
var_dump($entrada);
$options = array('location' => 'https://sim.digifred.net.br/frederico/nfse/ws/principal/wsdl');
var_dump($client->__getFunctions());
$result = $client->__soapCall($function, $entrada, $options);
echo 'Response: ';
print_r($result);
?>
nota.xml (4,1,KB)
Desde já obrigado.