File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes SOAP with Attachment. and WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "SOAP with Attachment. and WSDL" Watch "SOAP with Attachment. and WSDL" New topic

SOAP with Attachment. and WSDL

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361

I think I have a bit of confusion regarding SOAP with attachments.

I know that in SOAP with attachments. I can attach various attachments with various type, for example :

  • Binary attachments encoded with Base64
  • Direct binary attachments

  • The whole SOAP message is encapsulated and sent within a MIME message.
    My question is :
    If I used SOAP with attachments, is this described in the WSDL file ??? Since a tag in the message will reference an attachment within the MIME message, how can this be described in WDSL, or this is beyond the scope of WSDL and can JAX-WS be used in case of SOAP with attachments ??

    Thanks in advance

    Life is the biggest school
    Victor Bucutea
    Ranch Hand

    Joined: Nov 24, 2008
    Posts: 43
    Hi Khaled,

    SOAP attachements are not enabled by default. If you were do deploy a service like this :

    the Image object would be returned to the client, depending on the SOAP style ( document or rpc ), as an BASE64 encoding right into the XML .

    this would be the HTTP response headers :

    and this would be the SOAP response:

    <?xml version="1.0" ?>
    <S:Envelope xmlns:S="">
    <ns2:retrievePictureResponse xmlns:ns2="">
    <return xmlns="">iVBORwEWDx...</return>

    However, if you would use the @MTOM annotation when deploying, like this:

    Take note that MTOM is used as an optimization of transferring large amounts of data through soap.
    The server would optimize binary transfers through SOAP, that is use the attachment part of the SOAP message to encode the Image:

    HTTP response headers:

    And this would be the WSDL generated by the appserver :

    So to answer your question, yes in the case of MTOM, there are clear specifications in the WSDL ( wsp:Policy elements ) on how to encode large binary attachments into the SOAP message. For a weird reason I cannot get the SOAP attachment to work ( it's something related to my client JARs ), but you can see it in depth in Ivan Kriszan notes chapter 10.3.

    And BTW , ALL binary transfers are Base64 encoded. There is no such thing as a Direct binary attachment.

    PS all of this are based on what Ivan Kriszan has explained in his notes. This example is not mine.
    Ivan Krizsan
    Ranch Hand

    Joined: Oct 04, 2006
    Posts: 2198
    For the cases where MTOM is not used, take a look at the following references:
    MIME binding in WSDL 1.1:
    Attachment description in the WS-I Attachments Profile 1.0:

    The short answer to your question is: yes.
    Best wishes!
    Khaled Mahmoud
    Ranch Hand

    Joined: Jul 15, 2006
    Posts: 361

    Thanks for your reply. Surely I have to read about MTOM.

    But I have one small comment on what you said regarding binary attachments.

    And BTW , ALL binary transfers are Base64 encoded. There is no such thing as a Direct binary attachment.

    I have read in a course I download directly from Sun for free [Web Services Enabling Technologes], is that the whole SAOP request can be encapsulated within a MIME message, which contains both the SOAP request as the first attachment and the other attachments.The other attachments can have any encoding, not necessarily Base64, and be inserted in the request as is (Not necessarily base64).

    The example which the course listed

    Here is the link for the course :

    I agree. Here's the link:
    subject: SOAP with Attachment. and WSDL
    It's not a secret anymore!