<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.issweb.fiorilli.com.br/" xmlns:xd="http://www.w3.org/2000/09/xmldsig#"><soapenv:Header/><soapenv:Body><ws:gerarxd><GerarxdEnvio xmlns="http://www.abrasf.org.br/xd.xsd"><Rps xmlns="http://www.abrasf.org.br/xd.xsd"><InfDeclaracaoPrestacaoServico Id="pfxdefc702d-e819-803c-d679-8d4a9e161618"><Rps><IdentificacaoRps><Numero>1</Numero><Serie>"60"</Serie><Tipo>1</Tipo></IdentificacaoRps><DataEmissao>2022-09-22</DataEmissao><Status>1</Status></Rps><Competencia>2022-09-22</Competencia><Servico><Valores><ValorServicos>10.00</ValorServicos><Aliquota>3.0000</Aliquota></Valores><IssRetido>2</IssRetido><ResponsavelRetencao>1</ResponsavelRetencao><ItemListaServico>01.06</ItemListaServico><Discriminacao>descricao do servico</Discriminacao><CodigoMunicipio>5220454</CodigoMunicipio><ExigibilidadeISS>1</ExigibilidadeISS><MunicipioIncidencia>5220454</MunicipioIncidencia></Servico><Prestador><CpfCnpj><Cnpj>xxxxxxx</Cnpj></CpfCnpj><InscricaoMunicipal>30010174</InscricaoMunicipal></Prestador><Tomador><IdentificacaoTomador><CpfCnpj><Cpf>07390796383</Cpf></CpfCnpj></IdentificacaoTomador><RazaoSocial>wall</RazaoSocial><Endereco><Endereco>Rua araibu</Endereco><Numero>431</Numero><Complemento>casa</Complemento><Bairro>Centro</Bairro><CodigoMunicipio>2700102</CodigoMunicipio><Uf>AC</Uf><Cep>62900000</Cep></Endereco><Contato><Email>[email protected]</Email></Contato></Tomador><RegimeEspecialTributacao>6</RegimeEspecialTributacao><OptanteSimplesNacional>1</OptanteSimplesNacional><IncentivoFiscal>2</IncentivoFiscal></InfDeclaracaoPrestacaoServico><xd:Signature xmlns:xd="http://www.w3.org/2000/09/xmldsig#"><xd:SignedInfo><xd:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><xd:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><xd:Reference URI="#pfxdefc702d-e819-803c-d679-8d4a9e161618"><xd:Transforms><xd:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><xd:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></xd:Transforms><xd:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><xd:DigestValue>UCVbegjfVGEABGpckPSuJ7VajocvreOLm1TnRz9H3LY=</xd:DigestValue></xd:Reference></xd:SignedInfo><xd:SignatureValue>HjoQdG9eEWwUPPo66GPQqzJtzZNkwitDkmwCtiLl+tOdAjlapIQyfFCxjFBRypn1C9TahFY3ieXvSGwpiSL2AqZUQmKbHMFAoGwQgSjyM9DdbPbqmeaiPy8vrurA2Wg0a2Y0Bf8Wn4uObuZ53ZElR0qtY/Ll3+Fu5TFEdpAfsowfw2aP86DFeWkykp5cEb2Ge9lbt0qcmaUF2DXFa7Nv70sz8KsGVPLdDd3+y8gL5NeeVh2DU6mJtrze+3RgtK6XxB6XFN6I1Gwvtjg0LlMftQxWc5ChdoBwpKlOegEHg7fsZ+90CKob7sz7cWFrElXiZ4ayvCpkPr9tlVsRFtnqxw==</xd:SignatureValue><xd:KeyInfo><xd:X509Data><xd:X509Certificate>MIIH/DCCBeSgAwIBAgIIQApEysfNhtkwDQYJKoZIhvcNAQELBQAwdjELMAkGA1UEBhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxNjA0BgNVBAsTLVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsIGRvIEJyYXNpbCAtIFJGQjEaMBgGA1UEAxMRQUMgU0FGRVdFQiBSRkIgdjUwHhcNMjIwODAzMTczMDI1WhcNMjMwODAzMTczMDI1WjCCAQMxCzAJBgNVBAYTAkJSMRMwEQYDVQQKEwpJQ1AtQnJhc2lsMQswCQYDVQQIEwJHTzEXMBUGA1UEBxMOU0VOQURPU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Rmn5jKF1kbQ7tW/4l9n+POzJCxBJ27xXsyWGIWWrZC+KhfVyP9DRH0jhZEdgaoKUynbxRygpH4yr+xoUOuIRjhD1qp/m/s2DUtAnKIecYkQEGyA7jH0i5aKDKji2QihXOpIKTMyEzhaqNj3siGKoJjmrAKuqrmMq+9aYsEzmMdkzKF438oC0yH9B8t/I5dKy9sNDxQMSwQv+IJFK5pTzkOHxTuybS72JC9Itqb3jmQk66XSedOzk+gT8JKPSMjqHWyIZdA+wemI=</xd:X509Certificate></xd:X509Data></xd:KeyInfo></xd:Signature></Rps></GerarxdEnvio><username>x</usexxxxxxxxxrname><password>xxxxxxx</password></ws:gerarxd></soapenv:Body></soapenv:Envelope>
Esse é o xml gerado por esse código:
$xml = $xml = strlen($inputs->cpf_cnpj)===11?'<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.issweb.fiorilli.com.br/" xmlns:xd="http://www.w3.org/2000/09/xmldsig#"><soapenv:Header></soapenv:Header><soapenv:Body><ws:gerarNfse><GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"><Rps xmlns="http://www.abrasf.org.br/nfse.xsd"><InfDeclaracaoPrestacaoServico ><Rps><IdentificacaoRps><Numero>1</Numero><Serie>'.'"'.rand(1,99).'"'.'</Serie><Tipo>1</Tipo></IdentificacaoRps><DataEmissao>'.date('Y-m-d').'</DataEmissao><Status>1</Status></Rps><Competencia>'.date('Y-m-d').'</Competencia><Servico><Valores><ValorServicos>'.$cobrancaBD->valor_liquido.'</ValorServicos><Aliquota>3.0000</Aliquota></Valores><IssRetido>2</IssRetido><ResponsavelRetencao>1</ResponsavelRetencao><ItemListaServico>01.06</ItemListaServico><Discriminacao>descricao do servico</Discriminacao><CodigoMunicipio>5220454</CodigoMunicipio><ExigibilidadeISS>1</ExigibilidadeISS><MunicipioIncidencia>5220454</MunicipioIncidencia></Servico><Prestador><CpfCnpj><Cnpj>xxxxxxx</Cnpj></CpfCnpj><InscricaoMunicipal>30010174</InscricaoMunicipal></Prestador><Tomador><IdentificacaoTomador><CpfCnpj><Cpf>'.$inputs->cpf_cnpj.'</Cpf></CpfCnpj></IdentificacaoTomador><RazaoSocial>'.$inputs->nome.'</RazaoSocial><Endereco><Endereco>'.$inputs->rua.'</Endereco><Numero>'.$inputs->numero.'</Numero><Complemento>'.$inputs->complemento.'</Complemento><Bairro>'.$inputs->bairro.'</Bairro><CodigoMunicipio>'.$inputs->municipio.'</CodigoMunicipio><Uf>'.$inputs->estado.'</Uf><Cep>'.str_replace("-","",$inputs->cep).'</Cep></Endereco><Contato><Email>'.$inputs->email.'</Email></Contato></Tomador><RegimeEspecialTributacao>6</RegimeEspecialTributacao><OptanteSimplesNacional>1</OptanteSimplesNacional><IncentivoFiscal>2</IncentivoFiscal></InfDeclaracaoPrestacaoServico></Rps></GerarNfseEnvio><username>xxxxxxx</username><password>xxxxxxxx</password></ws:gerarNfse></soapenv:Body></soapenv:Envelope>':
'<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.issweb.fiorilli.com.br/" xmlns:xd="http://www.w3.org/2000/09/xmldsig#"><soapenv:Header></soapenv:Header><soapenv:Body><ws:gerarNfse><GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"><Rps xmlns="http://www.abrasf.org.br/nfse.xsd"><InfDeclaracaoPrestacaoServico Id='.'"'.$id_lote.'"'.'><Rps><IdentificacaoRps><Numero>1</Numero><Serie>'.'"'.rand(1,99).'"'.'</Serie><Tipo>2</Tipo></IdentificacaoRps><DataEmissao>'.date('Y-m-d').'</DataEmissao><Status>1</Status></Rps><Competencia>'.date('Y-m-d').'</Competencia><Servico><Valores><ValorServicos>'.$cobrancaBD->valor_liquido.'</ValorServicos><Aliquota>2.0000</Aliquota></Valores><IssRetido>2</IssRetido><ResponsavelRetencao>1</ResponsavelRetencao><ItemListaServico>01.05</ItemListaServico><Discriminacao>descricao do servico</Discriminacao><CodigoMunicipio>3504800</CodigoMunicipio><ExigibilidadeISS>1</ExigibilidadeISS><MunicipioIncidencia>3504800</MunicipioIncidencia></Servico><Prestador><CpfCnpj><Cnpj>01001001000113</Cnpj></CpfCnpj><InscricaoMunicipal>15000</InscricaoMunicipal></Prestador><Tomador><IdentificacaoTomador><CpfCnpj><Cnpj>'.$inputs->cpf_cnpj.'</Cnpj></CpfCnpj></IdentificacaoTomador><RazaoSocial>'.$inputs->nome.'</RazaoSocial><Endereco><Endereco>'.$inputs->rua.'</Endereco><Numero>'.$inputs->numero.'</Numero><Complemento>'.$inputs->complemento.'</Complemento><Bairro>'.$inputs->bairro.'</Bairro><CodigoMunicipio>'.$inputs->municipio.'</CodigoMunicipio><Uf>'.$inputs->estado.'</Uf><Cep>'.str_replace("-","",$inputs->cep).'</Cep></Endereco><Contato><Email>'.$inputs->email.'</Email></Contato></Tomador><OptanteSimplesNacional>2</OptanteSimplesNacional><IncentivoFiscal>2</IncentivoFiscal></InfDeclaracaoPrestacaoServico></Rps></GerarNfseEnvio><username>xxxxx</username><password>xxxxxxx</password></ws:gerarNfse></soapenv:Body></soapenv:Envelope>';
$file_name = uniqid().'_xml_gerar.xml';$file_name = uniqid().'_xml_gerar.xml';
$priKEY = __DIR__.'/certificado.pem';
$keypass = "12345";
$pubKEY = __DIR__.'/certificado.pem';
// Habilita a manipulação de erros da libxml
libxml_use_internal_errors(true);
//limpar erros anteriores que possam estar em memória
libxml_clear_errors();
// carrega o documento no DOM
$xmldoc = new DOMDocument('1.0', 'UTF-8');
$xmldoc->preservWhiteSpace = true; //elimina espaços em branco
$xmldoc->formatOutput = false;
// muito importante deixar ativadas as opções para limpar os espacos em branco
// e as tags vazias
if (!$xmldoc->loadXML($xml, LIBXML_NOBLANKS | LIBXML_NOXMLDECL | LIBXML_BIGLINES)) {
$msg = "Erro ao carregar XML, provavel erro no proprio xml!!";
$errors = libxml_get_errors();
if (!empty($errors)) {
$i = 1;
foreach ($errors as $error) {
$msg .= "\n [$i]-" . trim($error->message);
}
libxml_clear_errors();
}
throw new Exception($msg);
}
//extrair a tag com os dados a serem assinados
$xpath = new DOMXPath($xmldoc);
$xpath->registerNamespace('nfse', "http://www.abrasf.org.br/nfse.xsd");
$node = $xpath->query("//nfse:InfDeclaracaoPrestacaoServico")->item(0);
if (!isset($node)) {
$msg = "A tag <$tagid> não existe no XML!!";
throw new Exception($msg);
}
// Cria novo Security object
$objDSig = new XMLSecurityDSig('nfse');
// Usa a c14n exclusive canonicalization
$objDSig->setCanonicalMethod(XMLSecurityDSig::C14N);
// Assina usando SHA-1
$objDSig->addReference(
$node,
XMLSecurityDSig::SHA256,
[
"http://www.w3.org/2000/09/xmldsig#enveloped-signature",
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
],
array('id_name' => 'Id', "overwrite"=>false)
);
// Cria nova (private) Security key
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type'=>'private'));
$objKey->passphrase = "123456";
$objKey->loadKey(__DIR__.'/certificado.pem', TRUE);
// Assina o XML
$objDSig->sign($objKey);
// Adiciona a public key para a signature
$objDSig->add509Cert(file_get_contents(__DIR__ .'/certificado.pem'));
// Acrescenta a signature para o XML
$objDSig->appendSignature($node->parentNode);
$objDSig = null;
//grava na string o objeto DOM
$xml = $xmldoc->saveXML();
Pode me ajudar por favor