Segue abaixo um exemplo de consultarNfsePorRps no padrão SMARAPD.
public function consultaNFsePorRps(): stdClass
{
// Retorno
$return = new stdClass();
$return->status = 500;
$return->data = array("success" => false);
// Parametros
$rps_numero = $this->rps_id;
$rps_serie = $this->rps_serie;
$rps_tipo = "1";
$rps_cnpj = $this->conf->cnpj;
$rps_im = $this->conf->inscricaoMunicipal;
$envelope = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:nfse=\"http://nfse.abrasf.org.br\">
<soapenv:Header/>
<soapenv:Body>
<nfse:consultarNfsePorRps>
<xml><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ConsultarNfseRpsEnvio xmlns=\"http://www.abrasf.org.br/nfse.xsd\">
<IdentificacaoRps>
<Numero>$rps_numero</Numero>
<Serie>$rps_serie</Serie>
<Tipo>$rps_tipo</Tipo>
</IdentificacaoRps>
<Prestador>
<CpfCnpj>
<Cnpj>$rps_cnpj</Cnpj>
</CpfCnpj>
<InscricaoMunicipal>$rps_im</InscricaoMunicipal>
</Prestador>
</ConsultarNfseRpsEnvio>]]></xml>
</nfse:consultarNfsePorRps>
</soapenv:Body>
</soapenv:Envelope>";
$url = $this->end_prod;
if ($this->rps->ambienteEmissao && (strtolower($this->rps->ambienteEmissao) === "homologacao")){
$url = $this->end_homo;
}
$ret = $this->sendRequest($envelope, "", $url);
$html = $ret['html'];
$httpcode = $ret['code'];
if ($httpcode!=200){
preg_match_all('/<faultstring>(.*?)<\/faultstring>/s', html_entity_decode($html), $matches);
$response = (count($matches)&&count($matches[1])?$matches[1][0]:$html);
$return->data['errors'][] = [
"codigo" => $httpcode,
"mensagem" => $response,
"correcao" => ""
];
return $return;
}
// Extrai Retorno SOAP
preg_match_all('/<return>(.*?)<\/return>/s', html_entity_decode($html), $matches);
$response = (count($matches)&&count($matches[1])?$matches[1][0]:$html);
// Parse
$return->status = $httpcode;
$this->parseRetorno($response, $return);
return $return;
}