phax / ph-ubl

Java library for reading and writing UBL 2.0, 2.1, 2.2, 2.3 and 2.4 (CS01) documents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XML cut off on write

azyu1011 opened this issue · comments

Hello, I have a question,

When I use the UBL Marshaller, the XML is not generated completely; it always gets cut off at line 74. Does anyone know where my mistake is? Here is the code snippet:

private static InputStream invoiceToXmlAsInputStream(InvoiceType invoice) throws ReformException {
		InputStream inputStream;
		try {
			UBL21Marshaller.UBL21JAXBMarshaller<InvoiceType> marshaller = UBL21Marshaller.invoice();
			ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream();
			marshaller.setCharset(StandardCharsets.UTF_8);
			marshaller.setFormattedOutput(true);
			marshaller.write(invoice, byteBufferOutputStream);
			inputStream = new ByteArrayInputStream(byteBufferOutputStream.getAsByteArray());
		}
		catch (Exception ex) {
			LOGGER.error("UBL/XRechnung konnte nicht erstellt werden", ex);
			throw new ReformException(
					Translator.tr("UBL/XRechnung konnte nicht erstellt werden, bitte kontaktieren Sie den Support.", ReformHttpSession.getLocale()));
		}
		return inputStream;
	}

It can be closed.
I created some incorrect data, but the exceptions are not displayed.
I added ExceptionCallbacks, and now everything is fine.