![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
¿Como enviar facturas al web service?
Buenos días a todos
Estoy peleándome con el web service del Verifactu y quería preguntar como estáis haciendo para enviar los registros de facturas. En un código que está anclado en el foro vi que lo que se manda es el xml, pero me gustaría saber si es la única manera o hay algo parecido el envío en el SII, que puedes enviar el "objeto" SuministroLRFacturasEmitidas que construyes (en el caso del Verifactu sería el objeto "RegFactuSistemaFacturacion") El código que vi para enviar al Verifactu: Código:
Dim webRequest As HttpWebRequest = CType(Net.WebRequest.Create("...prewww1.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP"), HttpWebRequest)
webRequest.ContentType = "text/xml;charset=""utf-8"""
webRequest.Accept = "text/xml"
webRequest.Method = "POST"
webRequest.ClientCertificates.Add(certificate)
Using stream As Stream = webRequest.GetRequestStream()
doc.Save(stream) 'EN ESTE DOC ESTÁ EL XML
End Using
Dim response As HttpWebResponse = CType(webRequest.GetResponse(), HttpWebResponse)
Dim statusDescription As String = response.StatusDescription
Dim dataStream As Stream = response.GetResponseStream()
Dim responseFromServer As String
Using reader As StreamReader = New StreamReader(dataStream)
responseFromServer = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
End Using
Código:
Dim Ws As WSEmitidas.siiSOAPClient = New WSEmitidas.siiSOAPClient("SuministroFactEmitidasPruebas", New EndpointAddress("...prewww1.aeat.es/wlpl/SSII-FACT/ws/fe/SiiFactFEV1SOAP"))
Ws.Endpoint.Binding = binding
Ws.ClientCredentials.ClientCertificate.Certificate = certifikat
Dim RespuestaEnvioFactura As RespuestaLRFEmitidasType = Ws.SuministroLRFacturasEmitidas(ObjetoFacturaEmitida)
MsgBox(RespuestaEnvioFactura.EstadoEnvio)
|
|
#2
|
||||
|
||||
|
En este mensaje tienes un programa de ejemplo "completo" que ha publicado un forero (seccion_31) que incluye el envío del fichero utilizando HTTPRio.
El código fuente está disponible en Github, puedes revisarlo. El código simplificado es algo así:
__________________
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. |
|
#3
|
||||
|
||||
|
Si no me equivoco, se debería poder hacer de ambas maneras, generando tú el XML a mano o pasando por la función "RegFactuSistemaFacturacion", yo personalmente monto el XML a mano por ahora, pero como te dice neftali échale un ojo al github que te aclarará mas que cualquier respuesta.
__________________
La religión es personal e intransferible. |
|
#4
|
|||
|
|||
|
Gracias a ambos por las respuestas.
Es que estaba montando el objeto "RegFactuSistemaFacturacion" (como la hacía en el SII) Código:
Dim objectoFactEmitida As RegFactuSistemaFacturacion = New WSVerifactu.RegFactuSistemaFacturacion objectoFactEmitida.Cabecera = New CabeceraType objectoFactEmitida.Cabecera.ObligadoEmision = New PersonaFisicaJuridicaESType objectoFactEmitida.Cabecera.ObligadoEmision.NombreRazon = "AAAA" objectoFactEmitida.Cabecera.ObligadoEmision.NIF = "BBBB" objectoFactEmitida.Cabecera.Representante = New PersonaFisicaJuridicaESType objectoFactEmitida.Cabecera.Representante.NombreRazon = "CCCC" .... Porque al convertir el objeto "RegFactuSistemaFacturacion" al xml lo monta regular: las etiquetas no comienzan por "<sum:" o "<sum1:" y me dice que el xml es incorrecto. Si lo edito a mano poniendo los "sum " me funciona, pero es un poco rollo. También puedo olvidarme del objeto "RegFactuSistemaFacturacion" y montarlo a mano como dices, pero me parece más engorroso, quería agotar todas las vías antes Probaré lo que me decís a ver si avanzo algo Muchas gracias! |
|
#5
|
||||
|
||||
|
Revisa los mensajes existentes.
Ya hay muchos hablando del envío, donde puedes ver código.
__________________
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. |
|
#6
|
|||
|
|||
|
Cita:
Este código c# lo encontré en este foro, de algún compañero: Código:
var basicbinding = new BasicHttpsBinding(); basicbinding.Name = "sfVerifactu"; basicbinding.Security.Mode = BasicHttpsSecurityMode.Transport; basicbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; basicbinding.MaxReceivedMessageSize = 100 * 1024 * 1024; var service = new sfPortTypeVerifactuClient(basicbinding, new EndpointAddress(new Uri(url))); service.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(certificate); RespuestaRegFactuSistemaFacturacionType wsResponse = wsResponse = service.RegFactuSistemaFacturacion(objectoFactEmitida); ![]() |
|
#7
|
|||
|
|||
|
Cita:
|
|
#8
|
||||
|
||||
|
Cita:
__________________
La religión es personal e intransferible. |
|
#9
|
|||
|
|||
|
Cita:
Si no lo consigo de otra manera tendré que tirar por ahí, pero me parece mucho más cómo crear y mandar el objeto RegFactuSistemaFacturacion. Seguiré investigando y si lo consigo lo pongo aquí Muchas gracias igualmente! |
|
#10
|
|||
|
|||
|
Cita:
https://www.clubdelphi.com/foros/sho...postcount=3119 También te podría ser útil revisar los ejemplos publicados en el post #2: https://www.clubdelphi.com/foros/showthread.php?t=95235 Saludos |
|
#11
|
|||
|
|||
|
Conseguido
Buenas a todos
al final lo conseguí, pongo aquí el código por si puede ayudarle a alguien más: Código:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim ws As sfVerifactu = New WSVerifactu.sfVerifactu
ws.ClientCertificates.Add(certificate)
ws.Url = "https : // prewww1.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP" 'quitar los espacios
Dim RespuestaEnvioFactura As WSVerifactu.RespuestaRegFactuSistemaFacturacionType = ws.RegFactuSistemaFacturacion(objectoFactEmitida)
MsgBox(RespuestaEnvioFactura.EstadoEnvio & "/" & RespuestaEnvioFactura.RespuestaLinea.Length)
For x As Integer = 0 To RespuestaEnvioFactura.RespuestaLinea.Length - 1
MsgBox(RespuestaEnvioFactura.RespuestaLinea(x).IDFactura.NumSerieFactura.ToString & ": " & RespuestaEnvioFactura.RespuestaLinea(x).CodigoErrorRegistro & " - " & RespuestaEnvioFactura.RespuestaLinea(x).DescripcionErrorRegistro)
Next
Gracias a todos por la ayuda |
![]() |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Enviar información a los clientes desde un Web Service REST | chinchan | C++ Builder | 1 | 20-01-2023 21:51:20 |
| Como consumir un web service que usa SSL | AzidRain | Internet | 0 | 12-12-2013 20:38:02 |
| Tabla de Facturas vs Detalles de Facturas | magnu9 | Conexión con bases de datos | 9 | 27-07-2007 17:27:37 |
| Mi aplicacion como un Service | kavisch | Varios | 2 | 03-05-2006 21:51:51 |
| Campos calculados, facturas y detalles de facturas. | Letty | Conexión con bases de datos | 7 | 07-11-2003 11:19:44 |
|