none
SUNAT. Factura electrónica UBL 2.1. No se puede leer (parsear) el archivo XML (found <cbc:ID>) RRS feed

  • Pregunta

  • Hola.

    Necesito saber dónde está el problema en el fichero XML (factura electrónica) que genero. No soy capaz a encontrarlo. Agradezco cualquier idea.

    Al enviar al servicio web me devuelve el siguiente error:

          <soap-env:Fault>
             <faultcode>soap-env:Client.0306</faultcode>
             <faultstring>No se puede leer (parsear) el archivo XML - Detalle: http://xxx.xxx.xxx/ol-ti-itcpfegem-beta/billService: cvc-complex-type 2.4: in element {urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2}ExternalReference of type {urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2}ExternalReferenceType, found &lt;cbc:ID> (in namespace urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2), but next item should be end-element</faultstring>
          </soap-env:Fault>

    Este es el fichero XML que envío incluido en el correspondiente zip: 20100066603-01-F001-008.zip

    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<ext:UBLExtensions>
    		<ext:UBLExtension>
    			<ext:ExtensionContent><ds:Signature Id="SignatureSP"><SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>yKnfDyS3vvupKH0G4WURmnZ7Uf0=</DigestValue></Reference></SignedInfo><SignatureValue xmlns="http://www.w3.org/2000/09/xmldsig#">XLH2JMv78oZmxTFZHq5NpqkhjM81Z+0fHFXUPMl67SxgaPgXNmLxdwJQEyRoOoi6lFQ+Pk28b0cOeSSaMSGDWH7evDNrWDmXoqZt1aIWx7fy79Ja2zDw2ddD7rKBT+nZrdYqfPzzuuV7358i84rrncxjufLQE8VchY8+Ogr6Z8rKW+B8WWJ41wDe02K9HKQGysCZVma8POnGQvTOcgXq/vVkr1naf6ltIjeqYtwo7S1y/PoRT96kXUFeomZrtKawFsnNG7UqlLT+KkClyjtM0KFWAK8wsYmqVwApes889eMIDAFFEcNFje7Cz/S62VSP/XvyPuJt3nNSsfg5xQt73w==</SignatureValue><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><X509Data><X509SubjectName>E=demo@llama.pe, CN=NOMBRE REPRESENTANTE LEGAL - CERTIFICADO PARA DEMOSTRACIÓN, OU=DNI 9999999 RUC 20502687647 - CERTIFICADO PARA DEMOSTRACIÓN, O=TU EMPRESA S.A., L=LIMA, S=LIMA, C=PE, DC=LLAMA.PE SA</X509SubjectName><X509Certificate>MIIE+DCCA+CgAwIBAgIJAMzWWhpm/YBCMA0GCSqGSIb3DQEBBQUAMIIBDTEbMBkGCgmSJomT8ixkARkWC0xMQU1BLlBFIFNBMQswCQYDVQQGEwJQRTENMAsGA1UECAwETElNQTENMAsGA1UEBwwETElNQTEYMBYGA1UECgwPVFUgRU1QUkVTQSBTLkEuMUUwQwYDVQQLDDxETkkgOTk5OTk5OSBSVUMgMjA1MDI2ODc2NDcgLSBDRVJUSUZJQ0FETyBQQVJBIERFTU9TVFJBQ0nDk04xRDB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OCAQEASAL7cD4xj9GDbbyCA6C2ocWvdqt5ejrq0jUYIFXDyiqVZvfI9KP1fwvE3NKm60sQpG+KM7V/+yuxEiNero7Nk4RMKFGtcyJ0UL3knyDqRiMX/UuN0GQBAAJC6D5ABtDstYcZzZqywJRgc1GWzmJiP4ng/YSJkdQ5hUsPiKEkFcyrsIioKYhTN65tQqjVLgsAl+sgVUIfKXld4YXTSBu/UiV1q0IWD6fyCapGK6j/7BGhEsgl1/s58Z4MdXYuvFUgFDyVN1Lykx5ReJvStdSDz09s5gzijBwvgzQ23MzqgHLTVZld8Oo6jFo85bUFEWLMr3wW+Odc1alRNFY7lI4UDg==</X509Certificate></X509Data></KeyInfo></ds:Signature></ext:ExtensionContent>
    		</ext:UBLExtension> 
    	</ext:UBLExtensions> 
    	<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    	<cbc:CustomizationID>2.0</cbc:CustomizationID>
    	<cbc:ProfileID schemeAgencyName="PE:SUNAT" schemeName="SUNAT:Identificador de Tipo de Operación" schemeURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo17">0101</cbc:ProfileID>
    	<cbc:ID>F001-008</cbc:ID>
    	<cbc:IssueDate>2019-10-29</cbc:IssueDate>
    	<cbc:IssueTime>10:07:24</cbc:IssueTime>
    	<cbc:InvoiceTypeCode listAgencyName="PE:SUNAT" listName="SUNAT: Identificador de Tipo de Documento" listURI="urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo01">01</cbc:InvoiceTypeCode>
    	<cbc:Note languageLocaleID="1000"><![CDATA[CIENTO NOVENTA Y SEIS MIL Y 00/100 PESOS]]></cbc:Note>
    	<cbc:DocumentCurrencyCode listID="ISO 4217 Alpha" listAgencyName="United Nations Economic Commission for Europe" listName="Currency">PEN</cbc:DocumentCurrencyCode>
    	<cbc:LineCountNumeric>1</cbc:LineCountNumeric>
    	<cac:Signature>
    		<cbc:ID>IDSignSP</cbc:ID>
    		<cbc:Note>WinPYME</cbc:Note>
    		<cac:SignatoryParty>
    			<cac:PartyIdentification>
    				<cbc:ID>20100066603</cbc:ID>
    			</cac:PartyIdentification>
    			<cac:PartyName>
    				<cbc:Name><![CDATA[EsteEsElProveedor SAC]]></cbc:Name>
    			</cac:PartyName>
    		</cac:SignatoryParty>
    		<cac:DigitalSignatureAttachment>
    			<cac:ExternalReference>
    				<cbc:ID>#SignatureSP</cbc:ID>
    			</cac:ExternalReference>
    		</cac:DigitalSignatureAttachment>
    	</cac:Signature>
    	<cac:AccountingSupplierParty>
    		<cac:Party>
    			<cac:PartyIdentification>
    				<cbc:ID schemeID="6">20100066603</cbc:ID>
    			</cac:PartyIdentification>
    			<cac:PartyName>
    				<cbc:Name><![CDATA[EsteEsElProveedor SAC]]></cbc:Name>
    			</cac:PartyName>
    			<cac:PartyLegalEntity>
    				<cbc:RegistrationName><![CDATA[EsteEsElProveedor SAC]]></cbc:RegistrationName>
    				<cac:RegistrationAddress>
    					<cbc:AddressTypeCode>0000</cbc:AddressTypeCode>
    					<cbc:CityName><![CDATA[Vegadeo]]></cbc:CityName>
    					<cbc:CountrySubentity><![CDATA[Asturias]]></cbc:CountrySubentity>
    					<cbc:District><![CDATA[Distrito cero]]></cbc:District>
    					<cac:AddressLine>
    						<cbc:Line><![CDATA[Calle del buen suceso]]></cbc:Line>
    					</cac:AddressLine>
    				</cac:RegistrationAddress>
    			</cac:PartyLegalEntity>
    		</cac:Party>
    	</cac:AccountingSupplierParty>
    	<cac:AccountingCustomerParty>
    		<cac:Party>
    			<cac:PartyIdentification>
    				<cbc:ID schemeID="6">11223344556</cbc:ID>
    			</cac:PartyIdentification>
    			<cac:PartyLegalEntity>
    				<cbc:RegistrationName><![CDATA[Nombre del cliente]]></cbc:RegistrationName>
    			</cac:PartyLegalEntity>
    		</cac:Party>
    	</cac:AccountingCustomerParty>
    <cac:TaxTotal>
     <cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
     <cac:TaxSubtotal>
        <cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
        <cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
        <cac:TaxCategory>
           <cac:TaxScheme>
    <cbc:ID>1000</cbc:ID>
              <cbc:Name>IGV</cbc:Name>
              <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
           </cac:TaxScheme>
        </cac:TaxCategory>
     </cac:TaxSubtotal>
     </cac:TaxTotal>
     <cac:LegalMonetaryTotal>
       <cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
       <cbc:PayableAmount currencyID="PEN">236.00</cbc:PayableAmount>
     </cac:LegalMonetaryTotal>
     <cac:InvoiceLine>
    <cbc:ID>1</cbc:ID>
        <cbc:InvoicedQuantity unitCode="NIU">2</cbc:InvoicedQuantity>
        <cbc:LineExtensionAmount currencyID="PEN">200.00</cbc:LineExtensionAmount>
        <cac:PricingReference>
           <cac:AlternativeConditionPrice>
              <cbc:PriceAmount currencyID="PEN">118.000000</cbc:PriceAmount>
              <cbc:PriceTypeCode>01</cbc:PriceTypeCode>
           </cac:AlternativeConditionPrice>
        </cac:PricingReference>
        <cac:TaxTotal>
           <cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
           <cac:TaxSubtotal>
              <cbc:TaxableAmount currencyID="PEN">200.00</cbc:TaxableAmount>
              <cbc:TaxAmount currencyID="PEN">36.00</cbc:TaxAmount>
              <cac:TaxCategory>
                 <cbc:Percent>18</cbc:Percent>
                 <cbc:TaxExemptionReasonCode>10</cbc:TaxExemptionReasonCode>
                 <cac:TaxScheme>
    <cbc:ID>1000</cbc:ID>
                    <cbc:Name>IGV</cbc:Name>
                    <cbc:TaxTypeCode>VAT</cbc:TaxTypeCode>
                 </cac:TaxScheme>
              </cac:TaxCategory>
           </cac:TaxSubtotal>
        </cac:TaxTotal>
        <cac:Item>
           <cbc:Description><![CDATA[PROD 1]]></cbc:Description>
           <cac:SellersItemIdentification>
    <cbc:ID>P001</cbc:ID>
           </cac:SellersItemIdentification>
        </cac:Item>
        <cac:Price>
           <cbc:PriceAmount currencyID="PEN">100.000000</cbc:PriceAmount>
        </cac:Price>
     </cac:InvoiceLine>
    </Invoice>
    


    • Editado Unomasmas miércoles, 30 de octubre de 2019 10:14
    martes, 29 de octubre de 2019 21:17

Respuestas

  • He encontrado el problema. Dándole la enésima vuelta, ví que dentro del nodo <cac:Signature> tenía:

    <cac:DigitalSignatureAttachment>
    	<cac:ExternalReference>
    		<cbc:ID>#SignatureSP</cbc:ID>
    	</cac:ExternalReference>
    </cac:DigitalSignatureAttachment>
    

    Cuando lo apropiado es:

    <cac:DigitalSignatureAttachment>
    	<cac:ExternalReference>
    
    		<cbc:URI>#SignatureSP</cbc:URI>
    
    	</cac:ExternalReference>
    </cac:DigitalSignatureAttachment>
    
    Gracias.
    • Marcado como respuesta Unomasmas miércoles, 30 de octubre de 2019 8:50
    miércoles, 30 de octubre de 2019 8:50