Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 14-07-2021
Avatar de thinkows
thinkows thinkows is offline
Miembro
 
Registrado: mar 2020
Ubicación: Sabadell
Posts: 71
Poder: 5
thinkows Va por buen camino
Loados los hados del VB6

Cita:
Empezado por batuzail Ver Mensaje
Te recomiendo los componentes de Chilkat para generar los xml y para realizar el envío, lo estoy haciedo sobre VB6, y ya consigo enviar a Gipuzkoa, en Bizkaia me da error 400 y 415, creo que es algo de cabeceras que tendré que descubrir.
Yo uso CR8.5 y para generar el QR encontre un dll que lo genera y permite guardarlo como imagen, ya que la versión de CR no permite crear QR.


Si necesitas ayuda te puedo pasar ejemplos para el envío.


Saludos
Buenos días creía que era el único en desarrollar en anacrónico VB6 que alegría me has dado, yo también genero el xml y firmo con chilkat ... pero el envío a Guipuzkoa lo tengo muy verde, estoy probando con Advanced Rest Client de SoftEmule el ejemplo que ha puesto un compañero pero siempre me da error 500, podrías poner algun ejemplo de envio a Guipuzkoa ??? te estaría muy agradecido y si necesitas algo mi
aquí estoy ....

Saludos y gracias de antemano
Responder Con Cita
  #2  
Antiguo 14-07-2021
batuzail batuzail is offline
Miembro
 
Registrado: feb 2017
Posts: 57
Poder: 8
batuzail Va por buen camino
Cita:
Empezado por thinkows Ver Mensaje
Buenos días creía que era el único en desarrollar en anacrónico VB6 que alegría me has dado, yo también genero el xml y firmo con chilkat ... pero el envío a Guipuzkoa lo tengo muy verde, estoy probando con Advanced Rest Client de SoftEmule el ejemplo que ha puesto un compañero pero siempre me da error 500, podrías poner algun ejemplo de envio a Guipuzkoa ??? te estaría muy agradecido y si necesitas algo mi
aquí estoy ....

Saludos y gracias de antemano
Aqui tienes lo que tengo hasta el momento, está un poco guarrete y con cosas a piñón, ya que estoy de pruebas aún, pero como punto de partida te funcionará, por lo menos para Gipuzkoa, yo tengo que implemetar los tres envíos. Como ves usando Chilkat no es muy complejo, además hay ejemplos y utilidades https://tools.chilkat.io/xmlCreate.cshtml, puedes instalar una version trial de 30 dias.
Código:
Attribute VB_Name = "TicketBAI"
Option Explicit


Public Function GenerarXMLTbai() '(ejercicio As Integer, serie As String, factura As Long) As Boolean
Dim success As Long
Dim rsFactura As Recordset
Dim sSQL As String

success = 1
'  Create the XML to be signed...
Dim xmlToSign As New ChilkatXml
xmlToSign.Tag = "T:TicketBai"
success = xmlToSign.AddAttribute("xmlns:T", "urn:ticketbai:emision")
xmlToSign.UpdateChildContent "Cabecera|IDVersionTBAI", "1.2"
xmlToSign.UpdateChildContent "Sujetos|Emisor|NIF", "B00000034"
xmlToSign.UpdateChildContent "Sujetos|Emisor|ApellidosNombreRazonSocial", "HOTEL ADIBIDEZ"
xmlToSign.UpdateChildContent "Sujetos|Destinatarios|IDDestinatario|NIF", "B26248146"
xmlToSign.UpdateChildContent "Sujetos|Destinatarios|IDDestinatario|ApellidosNombreRazonSocial", "EMPRESA LANTEGIA"
xmlToSign.UpdateChildContent "Factura|CabeceraFactura|SerieFactura", "B2022"
xmlToSign.UpdateChildContent "Factura|CabeceraFactura|NumFactura", "0100"
xmlToSign.UpdateChildContent "Factura|CabeceraFactura|FechaExpedicionFactura", "30-01-2021"
xmlToSign.UpdateChildContent "Factura|CabeceraFactura|HoraExpedicionFactura", "18:00:17"
xmlToSign.UpdateChildContent "Factura|DatosFactura|DescripcionFactura", "Servicios Hotel"
xmlToSign.UpdateChildContent "Factura|DatosFactura|DetallesFactura|IDDetalleFactura|DescripcionDetalle", ""
xmlToSign.UpdateChildContent "Factura|DatosFactura|DetallesFactura|IDDetalleFactura|Cantidad", "1"
xmlToSign.UpdateChildContent "Factura|DatosFactura|DetallesFactura|IDDetalleFactura|ImporteUnitario", "55"
xmlToSign.UpdateChildContent "Factura|DatosFactura|DetallesFactura|IDDetalleFactura|Descuento", "0"
xmlToSign.UpdateChildContent "Factura|DatosFactura|DetallesFactura|IDDetalleFactura|ImporteTotal", "66.55"
xmlToSign.UpdateChildContent "Factura|DatosFactura|ImporteTotalFactura", "66.55"
xmlToSign.UpdateChildContent "Factura|DatosFactura|Claves|IDClave|ClaveRegimenIvaOpTrascendencia", "01"
xmlToSign.UpdateChildContent "Factura|TipoDesglose|DesgloseFactura|Sujeta|NoExenta|DetalleNoExenta|TipoNoExenta", "S1"
xmlToSign.UpdateChildContent "Factura|TipoDesglose|DesgloseFactura|Sujeta|NoExenta|DetalleNoExenta|DesgloseIVA|DetalleIVA|BaseImponible", "55.00"
xmlToSign.UpdateChildContent "Factura|TipoDesglose|DesgloseFactura|Sujeta|NoExenta|DetalleNoExenta|DesgloseIVA|DetalleIVA|TipoImpositivo", "21.00"
xmlToSign.UpdateChildContent "Factura|TipoDesglose|DesgloseFactura|Sujeta|NoExenta|DetalleNoExenta|DesgloseIVA|DetalleIVA|CuotaImpuesto", "11.55"
xmlToSign.UpdateChildContent "HuellaTBAI|EncadenamientoFacturaAnterior|SerieFacturaAnterior", "B2022"
xmlToSign.UpdateChildContent "HuellaTBAI|EncadenamientoFacturaAnterior|NumFacturaAnterior", "0099"
xmlToSign.UpdateChildContent "HuellaTBAI|EncadenamientoFacturaAnterior|FechaExpedicionFacturaAnterior", "29-01-2022"
xmlToSign.UpdateChildContent "HuellaTBAI|EncadenamientoFacturaAnterior|SignatureValueFirmaFacturaAnterior", "BeMkKwXaFsxHQec65SKpVP7EU9o4nUXOx7SAftIToFsxH+2j2tXPXhpBUnS26dhdSpiMl2DlTuqRsFdZfWyYazaGHgSRQHZZAnFt"
xmlToSign.UpdateChildContent "HuellaTBAI|Software|LicenciaTBAI", "TBAXXXXX"
xmlToSign.UpdateChildContent "HuellaTBAI|Software|EntidadDesarrolladora|NIF", "XXXXXX"
xmlToSign.UpdateChildContent "HuellaTBAI|Software|Nombre", "XXXXXXX"
xmlToSign.UpdateChildContent "HuellaTBAI|Software|Version", App.Major & "." & App.Minor & "." & App.Revision

FirmarXMLTbai xmlToSign

End Function

Public Function FirmarXMLTbai(xmlToSign As ChilkatXml) As Boolean
Dim gen As New ChilkatXmlDSigGen
Dim success As Long
    success = 1
    gen.SigLocation = "T:TicketBai"
    gen.SigLocationMod = 0
    gen.SigId = "Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-Signature"
    gen.SigNamespacePrefix = "ds"
    gen.SigNamespaceUri = "http://www.w3.org/2000/09/xmldsig#"
    gen.SigValueId = "Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-SignatureValue"
    gen.SignedInfoCanonAlg = "C14N"
    gen.SignedInfoDigestMethod = "sha256"
    
    '  Set the KeyInfoId before adding references..
    gen.KeyInfoId = "Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-KeyInfo"
    
    '  Create an Object to be added to the Signature.
    Dim object1 As New ChilkatXml
    object1.Tag = "xades:QualifyingProperties"
    success = object1.AddAttribute("xmlns:xades", "http://uri.etsi.org/01903/v1.3.2#")
    success = object1.AddAttribute("Id", "Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-QualifyingProperties")
    success = object1.AddAttribute("Target", "#Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-Signature")
    success = object1.AddAttribute("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#")
    success = object1.UpdateAttrAt("xades:SignedProperties", 1, "Id", "Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-SignedProperties")
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime", "TO BE GENERATED BY CHILKAT"
    success = object1.UpdateAttrAt("xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod", 1, "Algorithm", "http://www.w3.org/2001/04/xmlenc#sha512")
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue", "TO BE GENERATED BY CHILKAT"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName", "TO BE GENERATED BY CHILKAT"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber", "TO BE GENERATED BY CHILKAT"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier", "https://www.batuz.eus/fitxategiak/batuz/ticketbai/sinadura_elektronikoaren_zehaztapenak_especificaciones_de_la_firma_electronica_v1_0.pdf"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description", ""
    success = object1.UpdateAttrAt("xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod", 1, "Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256")
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue", "Quzn98x3PMbSHwbUzaj5f5KOpiH0u8bvmwbbbNkO9Es="
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyQualifiers|xades:SigPolicyQualifier|xades:SPURI", "https://www.batuz.eus/fitxategiak/batuz/ticketbai/sinadura_elektronikoaren_zehaztapenak_especificaciones_de_la_firma_electronica_v1_0.pdf"
    success = object1.UpdateAttrAt("xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat", 1, "ObjectReference", "#Reference-cf54e6a9-7bf2-4128-8cae-474a267a16a1")
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description", ""
    success = object1.UpdateAttrAt("xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Identifier", 1, "Qualifier", "OIDAsURN")
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Identifier", "urn:oid:1.2.840.10003.5.109.10"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Description", ""
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType", "text/xml"
    object1.UpdateChildContent "xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Encoding", ""
    
    success = gen.AddObject("", object1.GetXml(), "", "")
    '  -------- Reference 1 --------
    success = gen.AddSameDocRef("", "sha512", "C14N", "", "http://www.w3.org/2000/09/xmldsig#Object")
    success = gen.SetRefIdAttr("", "Reference-cf54e6a9-7bf2-4128-8cae-474a267a16a1")
    '  -------- Reference 2 --------
    success = gen.AddObjectRef("Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-SignedProperties", "sha512", "", "", "http://uri.etsi.org/01903#SignedProperties")
    '  -------- Reference 3 --------
    success = gen.AddSameDocRef("Signature-a53a6ab2-f904-4f7c-be64-603333f651bf-KeyInfo", "sha512", "", "", "")
    '  Provide a certificate + private key. (PFX password is test123)
    Dim cert As New ChilkatCert
    success = cert.LoadPfxFile("ruta.pfx", "1234")
    If (success <> 1) Then
        Debug.Print cert.LastErrorText
        Exit Function
    End If
    
    success = gen.SetX509Cert(cert, 1)
    
    gen.KeyInfoType = "X509Data+KeyValue"
    gen.X509Type = "Certificate"
    '  Load XML to be signed...
    Dim sbXml As New ChilkatStringBuilder
    success = xmlToSign.GetXmlSb(sbXml)
    gen.Behaviors = "IndentedSignature,TransformSignatureXPath"
    '  Sign the XML...
    success = gen.CreateXmlDSigSb(sbXml)
    If (success <> 1) Then
        Debug.Print gen.LastErrorText
        Exit Function
    End If
    '  Save the signed XML to a file.
    success = sbXml.WriteFile("c:\signedXml.xml", "utf-8", 0)
    'Debug.Print sbXml.GetAsString()
    
    VerificarFirmaXMLTbai sbXml
End Function
 
Public Function VerificarFirmaXMLTbai(sbXml As ChilkatStringBuilder) As Boolean
Dim verifier As New ChilkatXmlDSig
Dim success As Long
    success = 1
    success = verifier.LoadSignatureSb(sbXml)
    If (success <> 1) Then
        Debug.Print verifier.LastErrorText
        Exit Function
    End If
    
    Dim numSigs As Long
    numSigs = verifier.NumSignatures
    Dim verifyIdx As Long
    verifyIdx = 0
    Do While verifyIdx < numSigs
        verifier.selector = verifyIdx
        Dim verified As Long
        verified = verifier.VerifySignature(1)
        If (verified <> 1) Then
            Debug.Print verifier.LastErrorText
            Exit Function
        End If
    
        verifyIdx = verifyIdx + 1
    Loop
    Debug.Print "All signatures were successfully verified."
End Function

Public Sub EnviarXMLTbai()

Dim Http As New ChilkatHttp
Dim success As Boolean
success = Http.SetSslClientCertPfx("ruta.pfx", "1234")
If (success = False) Then
    Debug.Print Http.LastErrorText
    Exit Sub
End If

' Get the XML we wish to send in the body of the request.
Dim sbXml As New ChilkatStringBuilder
success = sbXml.LoadFile("c:\signedXml.xml", "utf-8")
If (success = False) Then
    Debug.Print ("Failed to load XML that is to be the HTTP request body")
    Exit Sub
End If

Dim url As String
url = "https://tbai-prep.egoitza.gipuzkoa.eus/WAS/HACI/HTBRecepcionFacturasWEB/rest/recepcionFacturas/alta"
Dim bGzip As Boolean
bGzip = True
Dim resp As ChilkatHttpResponse

Set resp = Http.PostXml(url, sbXml.GetAsString, "utf-8")
If (Http.LastMethodSuccess = False) Then
    Debug.Print (Http.LastErrorText)
    Exit Sub
End If

Http.ClearHeaders

Debug.Print ("response status code: " & resp.StatusCode)

' Examine the response (it is already decompressed)
Debug.Print ("response body:")
Debug.Print (resp.BodyStr)

End Sub
Responder Con Cita
  #3  
Antiguo 14-07-2021
Avatar de b4aronDeLaBirr4
b4aronDeLaBirr4 b4aronDeLaBirr4 is offline
Miembro
 
Registrado: jul 2021
Posts: 67
Poder: 3
b4aronDeLaBirr4 Va por buen camino
Disculpa, a ti no te sale este error al enviar? Me da el fichero como recibido pero me dice lo siguiente:

Código PHP:
<Codigo>008</Codigo>
            <
Descripcion>El mensaje ha sido modificado en tránsito o la firma no está bien realizada -- SignedInfo failed to verifyReference URI="" failed to verifyReference URI="#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties" failed to verifyReference URI="#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo" failed to verify. [src/xml2signatureobj.cpp(315)] - (10606)</ 
Responder Con Cita
  #4  
Antiguo 15-07-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Cita:
Empezado por b4aronDeLaBirr4 Ver Mensaje
Disculpa, a ti no te sale este error al enviar? Me da el fichero como recibido pero me dice lo siguiente:

Código PHP:
<Codigo>008</Codigo>
            <
Descripcion>El mensaje ha sido modificado en tránsito o la firma no está bien realizada -- SignedInfo failed to verifyReference URI="" failed to verifyReference URI="#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties" failed to verifyReference URI="#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo" failed to verify. [src/xml2signatureobj.cpp(315)] - (10606)</ 
Buenas,

A mí me ha dado ese error cuando no he enviado los datos en UTF8.

También debes cambiar los "signature" (solo hay dos diferentes) por otros que sean distintos para cada envío, para lo que puedes usar la función generateUuid() de la clase CkCrypt2.

Por ejemplo (código C++):

Cita:
CkCrypt2 crypt;
std::string sig=crypt.generateUuid();
std::string ref=crypt.generateUuid();

object1.AddAttribute("Id","Signature-"+sig+"-QualifyingProperties");
...
gen.SetRefIdAttr("","Reference-"+ref);
Responder Con Cita
  #5  
Antiguo 15-07-2021
Avatar de b4aronDeLaBirr4
b4aronDeLaBirr4 b4aronDeLaBirr4 is offline
Miembro
 
Registrado: jul 2021
Posts: 67
Poder: 3
b4aronDeLaBirr4 Va por buen camino
Genial! Voy a probar, muchas gracias! Pero cómo te aseguras que lo envías con esa codificación? Porque lo tengo en el código en varios puntos y luego lo tengo adjuntado en el header de la petición. Tú cómo lo estás haciendo?
Responder Con Cita
  #6  
Antiguo 15-07-2021
batuzail batuzail is offline
Miembro
 
Registrado: feb 2017
Posts: 57
Poder: 8
batuzail Va por buen camino
Cita:
Empezado por b4aronDeLaBirr4 Ver Mensaje
Genial! Voy a probar, muchas gracias! Pero cómo te aseguras que lo envías con esa codificación? Porque lo tengo en el código en varios puntos y luego lo tengo adjuntado en el header de la petición. Tú cómo lo estás haciendo?
Yo tengo el mismo problema de error en tránsito, le he metido utf-8 por todo slo sitios y sigo igual, alguien puede poner la firma y envío con Chilkat en VB6? estoy encallado. La firma está bien o eso dicen todos los validadores. Uso el ejemplo que genera las tools de Chilkat.
Responder Con Cita
  #7  
Antiguo 15-07-2021
Avatar de b4aronDeLaBirr4
b4aronDeLaBirr4 b4aronDeLaBirr4 is offline
Miembro
 
Registrado: jul 2021
Posts: 67
Poder: 3
b4aronDeLaBirr4 Va por buen camino
Lo mismo yo, aunque en C#
Responder Con Cita
  #8  
Antiguo 15-07-2021
batuzail batuzail is offline
Miembro
 
Registrado: feb 2017
Posts: 57
Poder: 8
batuzail Va por buen camino
Cita:
Empezado por batuzail Ver Mensaje
Yo tengo el mismo problema de error en tránsito, le he metido utf-8 por todo slo sitios y sigo igual, alguien puede poner la firma y envío con Chilkat en VB6? estoy encallado. La firma está bien o eso dicen todos los validadores. Uso el ejemplo que genera las tools de Chilkat.
El error era pq el nombre del cliente tenía un acento. ya podia ir probando cosas



Saludos
Responder Con Cita
  #9  
Antiguo 15-07-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Cita:
Empezado por batuzail Ver Mensaje
Yo tengo el mismo problema de error en tránsito, le he metido utf-8 por todo slo sitios y sigo igual, alguien puede poner la firma y envío con Chilkat en VB6? estoy encallado. La firma está bien o eso dicen todos los validadores. Uso el ejemplo que genera las tools de Chilkat.
Ten en cuenta que ese error también lo puede ocasionar un problema en el XML. Echa un vistazo a los encabezados de la respuesta. A mí, en una ocasión, me dijo tan claro lo que pasaba que no me lo creía.
Responder Con Cita
  #10  
Antiguo 15-07-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Cita:
Empezado por b4aronDeLaBirr4 Ver Mensaje
Genial! Voy a probar, muchas gracias! Pero cómo te aseguras que lo envías con esa codificación? Porque lo tengo en el código en varios puntos y luego lo tengo adjuntado en el header de la petición. Tú cómo lo estás haciendo?
Tengo mi propia función de conversión. Sé que Chilkat tiene varias formas de convertirlo aunque no las he usado.

IMPORTANTE: recuerda que hay que convertirlo a UTF8 antes de firmarlo.
Responder Con Cita
  #11  
Antiguo 15-07-2021
Avatar de b4aronDeLaBirr4
b4aronDeLaBirr4 b4aronDeLaBirr4 is offline
Miembro
 
Registrado: jul 2021
Posts: 67
Poder: 3
b4aronDeLaBirr4 Va por buen camino
¿Y en qué consiste esa función de conversión?
Responder Con Cita
  #12  
Antiguo 14-07-2021
Avatar de thinkows
thinkows thinkows is offline
Miembro
 
Registrado: mar 2020
Ubicación: Sabadell
Posts: 71
Poder: 5
thinkows Va por buen camino
De lujo compañero !!!!! muy agradecido voy ha probar
Responder Con Cita
  #13  
Antiguo 14-07-2021
Avatar de thinkows
thinkows thinkows is offline
Miembro
 
Registrado: mar 2020
Ubicación: Sabadell
Posts: 71
Poder: 5
thinkows Va por buen camino
Cita:
Empezado por batuzail Ver Mensaje
Aqui tienes lo que tengo hasta el momento, está un poco guarrete y con cosas a piñón, ya que estoy de pruebas aún, pero como punto de partida te funcionará, por lo menos para Gipuzkoa, yo tengo que implemetar los tres envíos. Como ves usando Chilkat no es muy complejo, además hay ejemplos y utilidades.
Muy agradecido por la info ... voy a probar

Última edición por Neftali [Germán.Estévez] fecha: 14-07-2021 a las 12:49:12. Razón: Corregir etiquetas
Responder Con Cita
  #14  
Antiguo 14-07-2021
skatologiko skatologiko is offline
Miembro
 
Registrado: jul 2021
Posts: 27
Poder: 0
skatologiko Va por buen camino
Otro problema que estoy teniendo es cuando quiero transmitir una factura de un NIF de fuera de España, que me dice el fichero no cumple el esquema XSD.
¿os ha pasado?
Responder Con Cita
  #15  
Antiguo 14-07-2021
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.331
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por skatologiko Ver Mensaje
Otro problema que estoy teniendo es cuando quiero transmitir una factura de un NIF de fuera de España, que me dice el fichero no cumple el esquema XSD.
¿os ha pasado?

¿Dónde la estás enviando?
y

¿Qué estás enviando? (puedes poner el trozo del XML)
(sección de <Destinatarios>)
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #16  
Antiguo 14-07-2021
batuzail batuzail is offline
Miembro
 
Registrado: feb 2017
Posts: 57
Poder: 8
batuzail Va por buen camino
Resuperar ds:SignatureValue

Hola,
Alguien sabe como recuperar la firma de un xml firmado con Chilckat?


Saludos
Responder Con Cita
  #17  
Antiguo 14-07-2021
batuzail batuzail is offline
Miembro
 
Registrado: feb 2017
Posts: 57
Poder: 8
batuzail Va por buen camino
Cita:
Empezado por batuzail Ver Mensaje
Hola,
Alguien sabe como recuperar la firma de un xml firmado con Chilckat?


Saludos
Ya lo he encontrado:
Dim xml as new ChilckatXml
.... cargamos el xml

ds_SignatureValue = xml.GetChildContent("ds:Signature|ds:SignatureValue")


Gracias
Responder Con Cita
  #18  
Antiguo 15-07-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Cita:
Empezado por batuzail Ver Mensaje
Hola,
Alguien sabe como recuperar la firma de un xml firmado con Chilckat?


Saludos
La mejor forma es con un analizador (parser) XML. El problema es hacerse con uno bueno.

Yo lo necesitaba para otras cosas y al final tuve que hacérmelo. No es difícil, aunque requiere bastantes horas de trabajo para pulirlo, pero una vez hecho es una delicia poder procesar cualquier XML sin despeinarse.

Si quieres salir del paso, puedes buscar "<ds:SignatureValue" en el texto. Una vez encontrado tienes que buscar el siguiente '>', apuntar la posición, buscar el siguiente '<', apuntar la posición, y extraer el fragmento comprendido entre las dos posiciones.
Responder Con Cita
  #19  
Antiguo 14-07-2021
skatologiko skatologiko is offline
Miembro
 
Registrado: jul 2021
Posts: 27
Poder: 0
skatologiko Va por buen camino
A Guipuzcoa. Si envío un NIF español, sí que llega

<Destinatarios>
<IDDestinatario>
<NIF>NL855820627B01</NIF>
<ApellidosNombreRazonSocial>ITX MERKEN B.V.</ApellidosNombreRazonSocial>
</IDDestinatario>
</Destinatarios>

Y me da el siguiente error:
Error: El fichero de alta TicketBAI no cumple el esquema XSD. Detalle del error: cvc-pattern-valid: Value 'NL855820627B01' is not facet-valid with respect to pattern '(([a-z|A-Z]{1}\d{7}[a-z|A-Z]{1})|(\d{8}[a-z|A-Z]{1})|([a-z|A-Z]{1}\d{8}))' for type 'NIFType'.</Descripcion>

Cita:
Empezado por Neftali [Germán.Estévez] Ver Mensaje
¿Dónde la estás enviando?
y

¿Qué estás enviando? (puedes poner el trozo del XML)
(sección de <Destinatarios>)
Responder Con Cita
  #20  
Antiguo 14-07-2021
skatologiko skatologiko is offline
Miembro
 
Registrado: jul 2021
Posts: 27
Poder: 0
skatologiko Va por buen camino
Bueno, parece que finalmente sí que consigo enviar el XML, recoger la firma para encadenar y generar el QR (al menos para Guipuzcoa)
Lo que no consigo es que dicho QR sea correcto. No sé si porque estoy obtieniendo el CRC mal, o cual es el motivo. (Y tampoco he visto ninguna url que funcione en todo el hilo)
Me genera la siguiente cadena:
https ://tbai.prep.gipuzkoa.eus/qr/?id=TBAI-B09500307-130521-YiT5C1USVoYiN-002&s=MP&nf=210914&i=5348.20&cr=245
No accede a la factura pero si accedo desde : https ://tbai.prep.gipuzkoa.eus/qr/verificar , ahí si que la encuentra
También he probado con: https ://tbai.egoitza.gipuzkoa.eus/qr/verificar ,pero ahí tampoco la encuentra ¿qué diferencia hay entre un subdominio y el otro?

La función en VB que utilizo para el cálculo del CRC es:

Public Function calculateCRC8(ByVal AppID As String) As String
Dim CRC8 As Byte
Dim i As Integer
Dim j As Integer
Dim AppIDarray() As Byte '<--- explicitly dimensioned as a Byte array to avoid confusion
Dim aidLength As Integer


CRC8 = &HC7

'The AppID is actually bytes stored in hexadecimal in a string. You have to convert them back to bytes before you can run a crc8 on them.
AppIDarray = HexToByte(AppID)
aidLength = UBound(AppIDarray)
For j = 0 To aidLength
CRC8 = CRC8 Xor AppIDarray(j)
For i = 1 To 8
If CRC8 And &H80 Then
'masking off the left-most bit before shifting prevents the Overflow error.
CRC8 = ((&H7F And CRC8) * 2) Xor &H1D
Else
CRC8 = CRC8 * 2
End If
Next i
Next j
calculateCRC8 = CRC8
End Function

Private Function HexToByte(strHex As String) As Byte()
Dim i As Integer
Dim j As Integer
Dim tempByte As Byte
Dim outBytes() As Byte
Dim Char As String
ReDim outBytes(Len(strHex) \ 2 - 1)
For i = 0 To Len(strHex) \ 2 - 1
For j = 0 To 1
Char = Mid(strHex, i * 2 + j + 1, 1)
Select Case Char
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9":
tempByte = tempByte Or (Asc(Char) - 48)
Case "A", "B", "C", "D", "E", "F":
tempByte = tempByte Or (Asc(Char) - 55)
End Select
If j = 0 Then
tempByte = tempByte * 2 ^ 4
Else
outBytes(i) = tempByte
tempByte = 0
End If
Next
Next
HexToByte = outBytes
End Function
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
SII -Nuevo sistema de la Agencia Tributaria española de envío de datos vía Webservice newtron Internet 3565 Hace 1 Día 11:04:13
Como utilizar la ayuda del nuevo Sistema Operativo gluglu Humor 3 24-09-2007 09:39:05
Aplicacion Agencia De Viajes ArdiIIa Varios 9 20-01-2007 16:49:53
El Vasco Aguirre Al González La Taberna 5 26-05-2006 09:22:28
Microsoft ha lanzado su nuevo sistema operativo DarkByte Humor 0 25-01-2004 09:21:14


La franja horaria es GMT +2. Ahora son las 19:08:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi