Adding MIME headers to MTOM Attachments...
I have been trying to get MTOM attachments working with a service client and have had a minor problem while sending files to the server. I am using JAX-WS 2.1.4 and SAAJ 1.3.2 but have verified the problem still exists in JAX-WS 2.2.7.
It seems the that the MtomCodec uses static MIME headers and doesn't allow someone to configure headers through the AttachmentPart.addMimeHeader() interface method.
The service I am communicating with is complaining that I have not specified the filename of the attachment in the content type. I have tried adding the "Content-Disposition" header:
DataSource ds = new FileDataSource(file);
AttachmentPart attachmentPart = soapMessage.createAttachmentPart(new DataHandler(ds));
attachmentPart.addMimeHeader("Content-Disposition", "attachment; name="" + file.getName() + """);
And if I use the SOAPMessage.writeTo(System.out) method, it shows the header in the message:
Content-Disposition: attachment; name="test_0001.csv"
However, capturing traffic using Charles Proxy reveals the header is not added to the actual message sent across the line:
I have traced out the found and found it was because the MtomCodec uses statically set headers.
I have reviewed the XOP and MTOM specs and realize the headers written do conform to the specs. However, tools such as SoapUI do include the "Content-Disposition" header when enabling MTOM which leads me to believe that this is not a non-standard implementation request.
Is this something that can be filed as a bug report?