cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Enrico Boldrini <>
Subject DataSource content-type using MTOM
Date Fri, 05 Mar 2010 15:42:56 GMT

I'm using MTOM attachments (with JAX-WS, not from schemas) following the 
instructions found on

The sample service is returning a Picture Object with a custom 
DataSource as following:

    @WebMethod(operationName = "GetPicture")
    public Picture getPicture() {
    Picture ret = new Picture();
    DataSource source = new DataSource() {

        public OutputStream getOutputStream() throws IOException {
        return null;

        public String getName() {
        return null;

        public InputStream getInputStream() throws IOException {
        return new ByteArrayInputStream(new byte[] { 10, 20 });

        public String getContentType() {
        return "image/png";
    ret.setImageData(new DataHandler(source));
    return ret;

This is the actual message stream flowing from the server to the client:

HTTP/1.1 200 OK
Content-Type: multipart/related; type="application/xop+xml"; 
start="<>"; start-info="text/xml"
Content-Length: 810
Server: Jetty(6.1.21)
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <>



Content-Type: image/png
Content-Transfer-Encoding: binary
Content-ID: <ccc0970b-980f-4bd0-bd90-5ffd4181a047-3@>


On the client side I can access the ByteArrayDataSource of the picture 
object. This has a correct input stream (as set in the service) but an 
incorrect content type "application/octet-stream". Note that the sniffed 
message contains the attachment with the correct content type "image/png".

This seems a bug IMHO, looking forward for your comments,


View raw message