Hi, I'm trying to send an MTOM attachment to an axis2 sample service that will copy the attachment data to a file. I can see the data being sent in the Logging Interceptor and the file gets created, but has zero bytes.
Code below: Map<String, Object> requestContext = client.getRequestContext () Collection<Attachment> attachments = new ArrayList<Attachment>(); AttachmentImpl attach = new AttachmentImpl("attachment-1"); attachments.add(attach); attach.setDataHandler(new DataHandler(new FileDataSource ('C:/tmp/keyfile.old'))) requestContext.put(Message.ATTACHMENTS, attachments); requestContext.put(Message.MTOM_ENABLED,"true") Logging output: 08/04/15 21:13:40.869 mtom1_21: LoggingOutInterceptorCXF: Outbound Message --------------------------- ID: 1 Address: http://localhost:8080/axis2/services/MTOMSample Encoding: UTF-8 Http-Method: POST Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9"; start="<root.mess...@cxf.apache.org>"; start-info="application/soap+xml"; action="attachment" Headers: {Accept=[*/*]} Payload: --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9 Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; action="attachment" Content-Transfer-Encoding: binary Content-ID: <root.mess...@cxf.apache.org> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:AttachmentRequest xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:ns2="http://ws.apache.org/axis2/mtomsample/"><ns2:fileName>c:/tmp/attach2.txt</ns2:fileName><ns2:binaryData xmime:contentType="text/plain"></ns2:binaryData></ns2:AttachmentRequest></soap:Body></soap:Envelope> --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-ID: <attachment-1> ##Do not Change this file## Custno=999 Company=UC4 Software Demonstration SAP=01-06-2009x01-06-2010x999 PSE=01-06-2009x01-06-2010x999 OAE=01-06-2009x01-06-2010x999 OAE-C=01-06-2009x01-06-2010x999 APPMASTER=01-06-2009x01-06-2010x999 EXPLORER+=01-06-2009x01-06-2010x999 AGENT=01-06-2009x01-06-2010x999 RME=01-06-2009x01-06-2010x999 JMS=01-06-2009x01-06-2010x999 APPWORX_WEBSERVICES=01-06-2009x01-06-2010x999 EXTERNAL_WEBSERVICES=01-06-2009x01-06-2010x999 ZOS=01-06-2009x01-06-2010x999 RA=01-06-2009x01-06-2010x999 RA_BUILDER=01-06-2009x01-06-2010x999 TESTAGENT=01-06-2009x01-06-2010x999 BANNERAGENT=01-06-2009x01-06-2010x999 FTPAGENT=01-06-2009x01-06-2010x999 VMWAREAGENT=01-06-2009x01-06-2010x999 --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9-- -------------------------------------- 08/04/15 21:13:40.879 mtom1_21: LoggingInInterceptorCXF: Inbound Message ---------------------------- ID: 1 Response-Code: 200 Encoding: UTF-8 Content-Type: application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse" Headers: {connection=[keep-alive], content-type=[application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"], Date=[Wed, 05 Aug 2015 04:13:40 GMT], Server=[Simple-Server/1.1], transfer-encoding=[chunked]} Payload: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">File saved succesfully.</ns2:AttachmentResponse> </soapenv:Body> </soapenv:Envelope> Roger This email (including any attachments) may contain information which is privileged, confidential, or protected. If you are not the intended recipient, note that any disclosure, copying, distribution, or use of the contents of this message and attached files is prohibited. If you have received this email in error, please notify the sender and delete this email and any attached files.