axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Malek, Hamid" <>
Subject SwA issue/bug
Date Fri, 29 Jun 2007 22:20:46 GMT
Trying not to be too verbose in this email, here is the short version
for those who don't like to read long emails:


Short version: 

It seems to me that the current implementation in Axis2-1.2 does not
have Mime Multipart/Related message formatter.


Longer version:

Back in the past when Axis2 was still at version 1.0 (axis2-1.0), I had
noticed that SwA was not fully supported and I sent an email to the dev
list explaining the importance of supporting SwA in Axis2. A year later
or so, we now voted ebMS-3 draft as a Committee Spec at Oasis ( ), and I
am about to embark on implementing ebMS-3 as an open source, based on
the Axis2 platform. First thing I did to verify that Axis2-1.2 fully
supports SwA, was to run the "soapwithattachments" example that comes
with the binaries. At the client side, I was attaching a jpg image, and
the webservice class was simply saving the attachment to a file. This
worked great. The second step was to look at the message itself (the
format of the message while traveling the network). So I needed a way to
log the request message to a file so that I look at it. All the snippet
codes out there (like a logging handler for example) were simply writing
out the SOAP envelope and not the whole message. Not finding the API to
do this, I had to quickly look at the source code of Axis2-1.2 to search
for how a message is being serialized in order to travel on the wire,
and I discovered that the code uses a MessageFormatter concept (which is
by the way a brilliant architecture design). I modified my webservice
class to instruct it to log the whole message to a file, by adding the
following method to the service class:


private void saveMessageToFile(MessageContext msgContext, File output)


    if (msgContext == null || output == null) return;

    OMOutputFormat format = new OMOutputFormat();








    Object mimeBoundaryProperty =


    if (mimeBoundaryProperty != null)

        format.setMimeBoundary((String) mimeBoundaryProperty);




      // adding this line does not do anything unfortunately




      MessageFormatter messageFormatter =



      FileOutputStream fos = new FileOutputStream(output); 

      byte[] msg = messageFormatter.getBytes(msgContext, format);





    catch(Exception ex) { ex.printStackTrace(); }



Then when I looked at the written message, I found this:



Content-Type: text/xml; charset=UTF-8

Content-Transfer-Encoding: 8bit

Content-ID: <>


<?xml version='1.0' encoding='UTF-8'?>

... (soap envelope here)


Content-Type: text/xml; charset=UTF-8

Content-Transfer-Encoding: binary

Content-ID: <>


<?xml version='1.0' encoding='UTF-8'?>

... (same soap envelope again - repeated twice)


Content-Type: image/jpeg

Content-Transfer-Encoding: binary

Content-ID: <urn:uuid:9C4F3190CC57C9117A1183150079369>

... (binary contents of the attached image)


The whole message is attached to this email. As you can see, the SOAP
Envelope was serialized twice and in the second time the
content-transfer-encoding is set to binary (the SOAP Envelope should be
serialized only once not twice). The second issue is that there is no
mime headers at the beginning of the message, before the first mime
part. The beginning of the message should start like this (before the
first mime part):


MIME-Version: 1.0

Content-Type: Multipart/Related; boundary=MIME_boundary; type=text/xml;


Content-Description: This is the optional message description.


Look at the W3C note to see the examples (

Mime Multipart/Related is a format that plays a crucial role (it is a
corner stone) in the B2B messaging space and it will stay that way for
some years to come. If Axis2 does not serialize SwA properly, it won't
be able to interoperate with an ebMS-3 implementation that is not based
on Axis2 and which expects the request message to arrive well formatted
(with the above mime headers first).

I can't emphasize enough the importance of Mime Multipart/Related format
in the B2B space. For Axis2 to be seriously leveraged in B2B (like being
the foundation of ebMS-3), this issue needs to be addressed.


If I am mistaken or missing something, please correct me as I am not
familiar with your code and just briefly looked at it. Otherwise, the
issue/bug would need to be addressed.


To summarize, here is what it should be done (assuming that I am not

*         Write a new class (MimeMultipartRelatedMsgFormatter) that
implements org.apache.axis2.transport.MessageFormatter interface

*         Declare this class in axis2.xml among the existing message

*         Modify AxisConfiguration class to return this class when
passed the string HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED in its
getMessageFormatter method.


Thank you.




P.S: I think Axis2 has lots of potential as I very much like its
architecture. The developers did a great job. I just want to thank you
all for this great work. 

View raw message