Om
java code to compress encode
public static byte[] compressEncode(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
byte[] buffer = new byte[8192];
int len;
while ((len = is.read(buffer)) > 0)
dos.write(buffer, 0, len);
dos.close();
byte[] encodedBytes = Base64.getEncoder().encode(baos.toByteArray());
baos.close();
is.close();
return encodedBytes;
}
some payload
-------
<SuministroLRFacturasRecibidasType xmlns:prx="urn:sap.com:proxy:DE1:/1SAI/TAS4E662B8C2E7563F4F897:740" xmlns:n0="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroInformacion.xsd" xmlns:n1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroLR.xsd">
<n1:SuministroLRFacturasRecibidas>
<n0:Cabecera>
<n0:IDVersionSii>1.1</n0:IDVersionSii>
<n0:Titular>
<n0:NombreRazon>Abbott Medical España, S.A.</n0:NombreRazon>
<n0:NIF>A79658845</n0:NIF>
</n0:Titular>
<n0:TipoComunicacion>A0</n0:TipoComunicacion>
</n0:Cabecera>
<n1:RegistroLRFacturasRecibidas>
<n0:PeriodoLiquidacion>
<n0:Ejercicio>2024</n0:Ejercicio>
<n0:Periodo>04</n0:Periodo>
</n0:PeriodoLiquidacion>
<n1:IDFactura>
<n0:IDEmisorFactura>
<n0:NIF>B97294771</n0:NIF>
</n0:IDEmisorFactura>
<n0:NumSerieFacturaEmisor>AIF 5</n0:NumSerieFacturaEmisor>
<n0:FechaExpedicionFacturaEmisor>09-04-2024</n0:FechaExpedicionFacturaEmisor>
</n1:IDFactura>
<n1:FacturaRecibida>
<n0:TipoFactura>F1</n0:TipoFactura>
<n0:ClaveRegimenEspecialOTrascendencia>01</n0:ClaveRegimenEspecialOTrascendencia>
<n0:DescripcionOperacion>Factura acreedor</n0:DescripcionOperacion>
<n0:RefExterna>302519000000102024</n0:RefExterna>
<n0:DesgloseFactura>
<n0:DesgloseIVA>
<n0:DetalleIVA>
<n0:TipoImpositivo>10.00</n0:TipoImpositivo>
<n0:BaseImponible>200.00</n0:BaseImponible>
<n0:CuotaSoportada>20.00</n0:CuotaSoportada>
</n0:DetalleIVA>
</n0:DesgloseIVA>
</n0:DesgloseFactura>
<n0:Contraparte>
<n0:NombreRazon>La Casa Maria</n0:NombreRazon>
<n0:NIF>B97294771</n0:NIF>
</n0:Contraparte>
<n0:FechaRegContable>09-04-2024</n0:FechaRegContable>
<n0:CuotaDeducible>20.00</n0:CuotaDeducible>
</n1:FacturaRecibida>
</n1:RegistroLRFacturasRecibidas>
</n1:SuministroLRFacturasRecibidas>
</SuministroLRFacturasRecibidasType>
------------
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.HashMap
import java.text.SimpleDateFormat
import java.util.Date
import java.util.zip.DeflaterOutputStream
import java.io.ByteArrayOutputStream
import java.util.Base64
def Message processData(Message message) {
// Get the XML payload from the message
def xmlPayload = message.getBody(java.lang.String) as String
// Convert XML payload to InputStream
def inputStream = new java.io.ByteArrayInputStream(xmlPayload.bytes)
// Compress and encode the InputStream
def compressedEncodedData = compressEncode(inputStream)
// Set the compressed and encoded data as the new payload
message.setBody(new String(compressedEncodedData, "UTF-8"))
return message
}
def compressEncode(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream()
DeflaterOutputStream dos = new DeflaterOutputStream(baos)
byte[] buffer = new byte[8192]
int len
while ((len = is.read(buffer)) > 0)
dos.write(buffer, 0, len)
dos.close()
byte[] encodedBytes = Base64.getEncoder().encode(baos.toByteArray())
baos.close()
is.close()
return encodedBytes
}
------------
eJzFVctum0AUXbdS/wFl3TBA/EQOErGxhJQ0lW1lW13D2JkKZujMEDv9q35Df6zDgHk45LErYsO5577OnTvM1nlKKBGSs9vVEiKZcxArHJEtiUFsnjNsHNOECjfjx+uLnFNXQGZGLFUAOz67i8B2kb32Q7Tx14NgNHJuJnMnGA9HV8vBcjIdu+OBdVHFoNb1xaOUmXAROhwOjgl7TCMCkpNtLoETMPdsa2KBhARJoh87kqgPlS1lFBEqMadYohhnCLKERBARRhVBvYBBIiEIQTvVBDoI1DQW0h3jqSabRxHX1dj/pZrblS7C+/L504za7pv6FyTFstw5bHGEOWhAI+HiAXOhMq4J8WzTnqFzsKZuiMwT4CWgkW8s3XK8gt+Mev52y6Q07nCsWkiMQGTw9w98Ndamb+qgbXIrRLj0/PF0NJxMBsOSp5AyJzpPWlaRsTlLc1op5flWRTzDdc/ovOlCqxXev6mUzvMdc8Jidkt+5cpQRyyNwU/MI6JAz7Gcgc7SQA2tiuFZJeX02XT3WpKiynBRVdcKGC6ClAjGu5ZayJvp2JkOxmO7K+Snaqh9vto1T9eqEFxZSprnh0ujmkivvfFf4ugRgmNWjF610KVZ00trcFnL9Cb3JMyL5gs9KuA0qlb+YvQn+tKuT8PLRucJPOFi+imm6oCqSJDcb9T8I0xjvbSeVfp/gNmEXWARcZIV/dxn6qDpOVbZDYg4xjHjOmwvswm0wrvgWNwH4F1ZztCeWvqxrVq+FqOTf58wgXtOxckUPvgnuMIlJEkHrqUM04wJIskT82zLtJr1ahk6TjegEigbJdsEq42onbqGjs88ZxLWLGNcghqmU/ucGeqiUW/VJ1XPmuzAPeeAUckhAy5xZ4VaN9QtGHMQYNwVF/gr99fH9u5lsnpn1AErrFCo07cnbXur+kKhBY7zqNK7I11jaLapb3W04Z2bUHPe+7PM0Lv/fu8faVyC1Q==
-----------
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.zip.InflaterInputStream
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.util.Base64
def Message processData(Message message) {
// Get the compressed and encoded payload from the message
def compressedEncodedPayload = message.getBody(java.lang.String) as String
// Decode the Base64 encoded payload
byte[] decodedBytes = Base64.getDecoder().decode(compressedEncodedPayload.getBytes("UTF-8"))
// Decompress the payload
def decompressedPayload = decompress(new ByteArrayInputStream(decodedBytes))
// Set the decompressed payload as the new payload of the message
message.setBody(new String(decompressedPayload, "UTF-8"))
return message
}
def decompress(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream()
InflaterInputStream iis = new InflaterInputStream(is)
byte[] buffer = new byte[8192]
int len
while ((len = iis.read(buffer)) > 0)
baos.write(buffer, 0, len)
iis.close()
baos.close()
return baos.toByteArray()
}
-------------
<SuministroLRFacturasRecibidasType xmlns:prx="urn:sap.com:proxy:DE1:/1SAI/TAS4E662B8C2E7563F4F897:740" xmlns:n0="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroInformacion.xsd" xmlns:n1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroLR.xsd">
<n1:SuministroLRFacturasRecibidas>
<n0:Cabecera>
<n0:IDVersionSii>1.1</n0:IDVersionSii>
<n0:Titular>
<n0:NombreRazon>Abbott Medical España, S.A.</n0:NombreRazon>
<n0:NIF>A79658845</n0:NIF>
</n0:Titular>
<n0:TipoComunicacion>A0</n0:TipoComunicacion>
</n0:Cabecera>
<n1:RegistroLRFacturasRecibidas>
<n0:PeriodoLiquidacion>
<n0:Ejercicio>2024</n0:Ejercicio>
<n0:Periodo>04</n0:Periodo>
</n0:PeriodoLiquidacion>
<n1:IDFactura>
<n0:IDEmisorFactura>
<n0:NIF>B97294771</n0:NIF>
</n0:IDEmisorFactura>
<n0:NumSerieFacturaEmisor>AIF 5</n0:NumSerieFacturaEmisor>
<n0:FechaExpedicionFacturaEmisor>09-04-2024</n0:FechaExpedicionFacturaEmisor>
</n1:IDFactura>
<n1:FacturaRecibida>
<n0:TipoFactura>F1</n0:TipoFactura>
<n0:ClaveRegimenEspecialOTrascendencia>01</n0:ClaveRegimenEspecialOTrascendencia>
<n0:DescripcionOperacion>Factura acreedor</n0:DescripcionOperacion>
<n0:RefExterna>302519000000102024</n0:RefExterna>
<n0:DesgloseFactura>
<n0:DesgloseIVA>
<n0:DetalleIVA>
<n0:TipoImpositivo>10.00</n0:TipoImpositivo>
<n0:BaseImponible>200.00</n0:BaseImponible>
<n0:CuotaSoportada>20.00</n0:CuotaSoportada>
</n0:DetalleIVA>
</n0:DesgloseIVA>
</n0:DesgloseFactura>
<n0:Contraparte>
<n0:NombreRazon>La Casa Maria</n0:NombreRazon>
<n0:NIF>B97294771</n0:NIF>
</n0:Contraparte>
<n0:FechaRegContable>09-04-2024</n0:FechaRegContable>
<n0:CuotaDeducible>20.00</n0:CuotaDeducible>
</n1:FacturaRecibida>
</n1:RegistroLRFacturasRecibidas>
</n1:SuministroLRFacturasRecibidas>
</SuministroLRFacturasRecibidasType>
-----------------
eJyzySvNTUotKrbj5VIAAhsg19DO0MjYRh/MQogaA0VNwKLGQFEwA6wPAEUWEdw=
import com.sap.gateway.ip.core.customdev.util.Message
import java.util.zip.InflaterInputStream
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.util.Base64
def Message processData(Message message) {
// Get the compressed and encoded payload from the message
def compressedEncodedPayload = message.getBody(java.lang.String) as String
// Decode the Base64 encoded payload
byte[] decodedBytes = Base64.getDecoder().decode(compressedEncodedPayload.getBytes("UTF-8"))
// Decompress the payload
def decompressedPayload = decompress(new ByteArrayInputStream(decodedBytes))
// Set the decompressed payload as the new payload of the message
message.setBody(new String(decompressedPayload, "UTF-8"))
return message
}
def decompress(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream()
InflaterInputStream iis = new InflaterInputStream(is)
byte[] buffer = new byte[8192]
int len
while ((len = iis.read(buffer)) > 0)
baos.write(buffer, 0, len)
iis.close()
baos.close()
return baos.toByteArray()
}
<numbers>
<num1>123</num1>
<num3>124</num3>
</numbers>
--------------