Hi,
TL;DR When cxf returns the object for the operation it contains everything but
the actual filecontent. The InputStream in the DataHandler has 0 bytes.
We are using CXF Codegen 4.1.1 and WSS4J 4.0.0.
* mtom/xop enabled
*
ws-security.store.bytes.in.attachment = false
With log output and interceptors we can confirm that the attachment is
available in the org.apache.cxf.binding.soap.SoapMessage and can be accessed
using the getAttachments() method (we can store the file in the interceptor and
read it correctly).
The relevant xml looks as follows (and it is a multipart message with a part
identified by the cid available):
<pams:filepart ordersequence="1" contenttype="1" extension="pdf">
<pams:filedescription
filename="/opt/EAD_data_pams/download/bas400000000862/bas730/file1.pdf" />
<pams:sha1>191B8B8551FCEF3EFEA154BEE9C1C1DA685AD74D</pams:sha1>
<pams:filecontent>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:[email protected]" />
</pams:filecontent>
</pams:filepart>
This code:
log.info("DataHandler name: {}", dataHandler.getName());
log.info("DataHandler DS class: {}", dataHandler.getDataSource().getClass());
log.info("Content type: {}", dataHandler.getContentType());
inputStream = dataHandler.getInputStream();
int available = inputStream.available();
log.info("InputStream available bytes: {}", available);
// double-check: Read all bytes first
byte[] bytes = inputStream.readAllBytes();
log.info("Size of file to write: {} bytes", bytes.length);
gives the following log output
DataHandler name: null
DataHandler DS class: class com.sun.istack.ByteArrayDataSource
Content type: application/octet-stream
InputStream available bytes: 0
Size of file to write: 0 bytes
File written successfully to 400000000862730.pdf
We have debugged into
org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.UnmarshallerImpl (
a JAXBAttachmentUnmarshaller class is instanced)
and when we look in retVal in UnmarshallerImpl.unmarshal0 (below) it contains
the empy InputStream.
XmlVisitor h = createUnmarshallerHandler(null,false,expectedType);
StAXConnector connector=StAXStreamConnector.create(reader,h);
try {
connector.bridge();
} catch (XMLStreamException e) {
throw handleStreamException(e);
}
Object retVal = h.getContext().getResult();
h.getContext().clearResult();
return retVal;
The package org.glassfish.jaxb.runtime.v2.runtime.unmarshaller does not include
any logging which makes it more challenging in determining where it goes wrong
(cxf, wss4j and/or jaxb unmarshaling).
Any advise would be highly appreciated as we are running out of ideas at the
moment and can seem to figure out where the unmarshaling is going wrong.
Are there additional properties and/or logging options that we can set to
resolve/pinpoint this?
Best Regards,
Jimisola