I have developed a web-service which receives multiple attachments from
a remote web-service via an CXF JAXB client (the client is called from
the service), the attachment from the remote service are, one xml
document and an undefined number of pdf documents.
When I try to add the received attachments to my web-service response
the xml document is set and only n-1 data of the received pdf documents.
Logging:
---------------------------
ID: 8
Encoding: UTF-8
Content-Type: multipart/related; type="application/xop+xml";
boundary="uuid:aeb23655-314b-4365-822c-f56f674059d8";
start="<[email protected]>"; start-info="text/xml"
Headers: {}
Payload:
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>...</soap:Envelope>
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<?xml version="1.0" encoding="UTF-8"?><ns2:Response
xmlns:ns2="ns://example.org/types">...</ns2:Response>
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
%PDF-1.4
%????
3 0 obj <</Filter/FlateDecode/Length 1137>>stream....
%%EOF
--uuid:aeb23655-314b-4365-822c-f56f674059d8
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
--uuid:aeb23655-314b-4365-822c-f56f674059d8--
Source code:
response.setXmlStream(getXmlResponseSource());
for(int i=0; i < client.getResponse().getAttachments().size(); i++){
DataHandler dh =
client.getResponse().getAttachments().get(i).getPDFOutStream();
DataSource source = dh.getDataSource();
response.getPdfStream().add(new
DataHandler(source.getInputStream(), "application/pdf"))
}
I have no idea why the last pdf document is not set.
Alex